|
From: Stavros M. <mac...@gm...> - 2024-10-13 17:25:06
|
I don't understand the problem.
Why would you expect *subst* to evaluate the variables *b* and *c *inside a
quoted expression?
-s
On Sun, Oct 13, 2024 at 12:25 PM Eduardo Ochs <edu...@gm...> wrote:
> Hi list,
>
> these are my current notes on the semantics of makelist:
>
>
> --snip--snip--
> format([args]) :=
> apply(?format, append([false], args));
>
> [a:b, b:c, c:d]; /* [b,c,d] */
> ['a, a, ''a, ''''a]; /* [a,b,c,d] */
> f1(o) ::= format("~a", o); /* just lispify */
> f2(o) := format("~a", o); /* ev and lispify */
>
> f1('a); /* ((MQUOTE SIMP) $A) */
> f1 (a); /* $A */
> f2('a); /* $A */
> f2 (a); /* $B */
>
> f1(2+3); /* 5 */
> f1(lambda([], 2+3)); /* ((LAMBDA SIMP) ((MLIST)) ((MPLUS) 2 3)) */
>
> makelist([a,b,c], a, 42,43); /* [[42,c,d], [43,c,d]] */
> makelist([a,b,c], ''a, 42,43); /* [[b,42,d], [b,43,d]] */
> makelist([a,b,c], ''''a, 42,43); /* [[b,c,42], [b,c,43]] */
>
> ev ('[a,b,c], a=42); /* [42,c,d] */
> ev ('[a,b,c], ''a=42); /* [b,42,d] */
> ev ('[a,b,c], ''''a=42); /* [b,c,42] */
>
> makelist([a,b,c], 'a, 42,43); /* [[42,c,d], [43,c,d]] */
> makelist([a,b,c], x+y, 42,43); /* [[b,c,d], [b,c,d]] */
>
> ev('[a,b,c], a=42); /* [42,c,d] */
> ev('[a,b,c], 'a=42); /* [42,c,d] */
> ev('[a,b,c], x+y=42); /* [b,c,d] */
>
> sublis([x+y=42], '[a,b,c]); /* err */
> subst ([x+y=42], '[a,b,c]); /* [a,b,c] */
> subst ( '[a=42], '[a,b,c]); /* [42,b,c] */
> subst ('['a=42], '[a,b,c]); /* [a,b,c] */
> --snip--snip--
>
>
> And here is just the bit that I don't understand, with less context:
>
>
> --snip--snip--
> [a:b, b:c, c:d];
> makelist([a,b,c], a,42,43); /* [[42,c,d], [43,c,d]] */
> makelist([a,b,c], 'a,42,43); /* [[42,c,d], [43,c,d]] */
> ev ('[a,b,c], a=42); /* [42,c,d] */
> ev ('[a,b,c], 'a=42); /* [42,c,d] */
> subst('[ a=42], '[a,b,c]); /* [42,b,c] */
> subst('['a=42], '[a,b,c]); /* [a,b,c] */
> --snip--snip--
>
>
> Note that:
> the quote in the "a" did not matter in the two "makelist"s above,
> the quote in the "a" did not matter in the two "ev"s above,
> the quote in the "a" _did_ matter in the two "subst"s above.
>
> So... all my attempts to translate the "ev"s above to "subst"s have
> failed miserably, my mental buffer has overflown, and I can't find a
> way to draw the orders of evaluation in a way that explains why the
> quotes on some "a"s don't matter... I _guess_ that I might be able to
> solve that after sleeping a lot, but I thought that the question was
> interesting enough, and worth asking...
>
> Btw, here is a too-short version of the question. Is there a
> straightforward way to translate the two "ev"s below to "subst"s?
> How? Note the "a=42" and the "'a=42"...
>
> [a:b, b:c, c:d];
> ev('[a,b,c], a=42); /* [42,c,d] */
> ev('[a,b,c], 'a=42); /* [42,c,d] */
>
>
> Cheers, and thanks in advance!
> Eduardo Ochs
> http://anggtwu.net/eev-maxima.html
> _______________________________________________
> Maxima-discuss mailing list
> Max...@li...
> https://lists.sourceforge.net/lists/listinfo/maxima-discuss
>
|