How using funmake with strings



On 10/15/06, john.masse <john.masse at appedge.com> wrote:
> aa(x):=block([],x*x);
> d:funmake(concat("a","a"),[]);
> ev(dd); /* gives aa(x) not x^2*/
> aa(x); /* gives 4 -> OK */

Maxima distinguishes between strings and identifiers.  Strings are
written as "xxx" and identifiers are written xxx, without the quotes.
You can assign values to identifiers, but not to strings:

         xxx : 3             OK
         "xxx" : 3           error

Normal display (display2d:true) does not display strings and
identifiers differently.  One-d display (display2d:false) does.

         display2d:true$         (the default)
         "xxx" => xxx
         xxx => xxx
         display2d: false$
         "xxx"  => "xxx"
        xxx    => xxx

When you concatenate two strings, you get a new string.  If you
concatenate a string to an identifier, you get an identifier:

       concat("a","b") => "ab"
       concat(a, "b") => ab

So in your above example, you can simply write concat(a,"a") or,
better, concat('a,"a") (this avoids interference in case the
identifier a has been assigned a value).

Now, as to your next question:

> d(2);
> d evaluates to aa(x)
> Improper name or value in functional position.

With the corrected definitions:

> aa(x):=block([],x*x);
> d:funmake(concat('a,"a"),[]);

d will now have the value aa().  ev(d) will give an error, because aa
takes one argument, not zero.  d(2) will give an error because d
evaluates to aa(), and (aa())(2) is not well-defined.  What is the
purpose of the 'funmake' here?  Why not just write d:concat('a,"a")
then d(2)? or even (concat('a,"a"))(2) ?

What are you trying to accomplish with the funmake and the concat?

        -s