Message Boards Message Boards

0
|
364 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Syntax error: ... more input needed

I wanted to demonstrate that linear regressions are not just for finding straights lines that fit a set of points but also is more general. For this I wrote, in part, this trivial function:

randomRow[] := Module[{x, col}, 
   x = RandomReal[1];
   col = {1.0, x, x^2, x^3, x^4};
   col];

I got the syntax error that more input was needed. When I deleted and reentered the col = {} line, the error disappeared. Apparently, I must have entered some unprintable characters which caused the error.

Is there a way to show these "illegal" characters in the notebook so I can fix the problem without resorting to retyping an entire notebook?

POSTED BY: Lawrence Winkler
2 Replies

This has happened to me before. I published a package some time ago, and have not been able to update it, after making some additions and cleaning up some code. I went to a lot of effort trying to find that unprintable character or characters.

I was happy to see this error appear again here in a way I could prove to myself that I was able to fat-finger code entry on my Mac in a tiny isolated piece of code. On hindsight, I should have preserved the flawed notebook before changing the few lines to find the fat-fingered line itself.

POSTED BY: Lawrence Winkler
Posted 2 months ago

It's really difficult to help with the information you've provided. First, it would be nice to have the exact error message, including the message name (it'll look like SomeSymbol::sometag). Second, how do you know there were unprintable characters in that code? Do you know what characters they actually were? Has this ever happened before, and if so, have you tried to find a pattern for how you are inadvertently entering unprintable characters? Does your worry that you'd need to retype the entire notebook mean that you've gotten this error multiple times?

And I know you didn't ask, but you could create your list like this:

RandomReal[]^Range[0, 4]

Bundling that into a function (with a parameter to avoid magic literals):

randomRow[length_] := RandomReal[]^Range[0, length - 1]
POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract