On 05/30/2011 02:54 PM, Edwin Woollett wrote:
> I get premature termination at $ error below:
> -------------------------
> (%i1) display2d:false$
> (%i2) l1 : "is much simplified"$
> (%i3) l2 : "is much simplified if"$
> (%i4) l1s : split (l1);
> (%o4) ["is","much","simplified"]
> (%i5) l2s : split (l2);
> (%o5) ["is","much","simplified","if"]
> (%i6) map ('parse_string,l1s);
> (%o6) [is,much,simplified]
> (%i7) map ('parse_string,l2s);
> incorrect syntax: Premature termination of input at $.
>
> (%i8) map('parse_string,["only","if"]);
> incorrect syntax: Premature termination of input at $.
> (%i9) parse_string ("if");
> incorrect syntax: Premature termination of input at $.
>
> Is there a fix for this?
>
> Ted Woollett
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
Hi Ted:
I tried:
l1 : "is much simplified"$
l2 : "is much simplified if more"$
l1s : split (l1);
l2s : split (l2);
map ('parse_string,l1s);
trace( parse_string );
map ('parse_string,l2s);
untrace( parse_string );
and got:
(%o173) ["is","much","simplified"]
(%o174) ["is","much","simplified","if","more"]
(%o175) [is,much,simplified]
(%o176) [parse_string]
1" Enter "parse_string["is"]
1" Exit "parse_string is
1" Enter "parse_string["much"]
1" Exit "parse_string much
1" Enter "parse_string["simplified"]
1" Exit "parse_string simplified
1" Enter "parse_string["if"]
stdin:3:incorrect syntax: Premature termination of input at $.
(%o178) [parse_string]
which tells me, I think, it's choking on the 'if'.
When I change:
l2 : "is much simplified has more"$
I get:
(%o182) ["is","much","simplified"]
(%o183) ["is","much","simplified","has","more"]
(%o184) [is,much,simplified]
(%o185) [parse_string]
1" Enter "parse_string["is"]
1" Exit "parse_string is
1" Enter "parse_string["much"]
1" Exit "parse_string much
1" Enter "parse_string["simplified"]
1" Exit "parse_string simplified
1" Enter "parse_string["has"]
1" Exit "parse_string has
1" Enter "parse_string["more"]
1" Exit "parse_string more
(%o186) [is,much,simplified,has,more]
(%o187) [parse_string]
A successful completion.
Does the Maxima documentation:
Function: parse_string (str)
Parse the string str as a Maxima expression (do not evaluate it). The
string str may or may not have a terminator (dollar sign $ or semicolon
;). Only the first expression is parsed, if there is more than one.
mean that 'is' is interpreted as the first expression and 'if' as the
second?
Paul