Subject: Newbie question: testing for lvalue (correction)
From: Michel Van den Bergh
Date: Mon, 01 Jan 2007 12:17:52 +0100
Actually your function is not quite correct. P((a+b)[3]) returns true
whereas it should
return false (one can argue that (a+b)[3] has no meaning if a,b are unbound,
but maxima does not throw an error).
The following seems to work always
P(e) := (symbolp(e) or (subvarp(e) and P(part(e,0)))) and not ?mstringp(e);
Robert Dodier wrote:
> On 12/31/06, Michel Van den Bergh <michel.vandenbergh at uhasselt.be> wrote:
>
>> Hmm, a string is not an lvalue (something that can appear on the
>> left hand side of an assignment). "describe" claims that there is
>> a function "stringp" but on my version of maxima stringp appears
>> not to do anything. Is this a bug?
>
>
> It turns out stringp is defined in an add-on package (namely stringproc).
> Probably it should move into the main source code.
> Be that as it may, the function ?mstringp has the desired effect.
> So we can update the test function to
>
> P(e) := (symbolp(e) or subvarp(e)) and not ?mstringp(e);
>
> Sorry, I could have included that to begin with. Hope this helps.
>
> Robert