create_list makelist possible bugs



On Mon, Sep 8, 2008 at 5:19 PM, John Lapeyre <pdl at johnlapeyre.com> wrote:

> Thanks for helping! Unforunately,
> the result I'm looking for is [1,2], like this ...
>
> (%o7) mtd(expr,v):=block([a:inpart(v,1),b:inpart(v,2)],
>       create_list(expr,a,1,b))
> (%i8) mtd(x,[x,2]);
> (%o8) [x,x]
> (%i9) mtc(expr,v) := apply('create_list, [expr,inpart(v,1),1,inpart(v,2)]);
> (%i10) mtc(x,[x,2]);
> (%o10) [1,2]

(1) Well, create_list and makelist are both implemented as argument-quoting
functions, which evaluate their arguments in a way appropriate to list
construction (evaluating the first argument after binding the loop variables,
I would guess). Given that, "apply" is a way to get the expected behavior.
Maybe the documentation could be improved.

(2) Are you really going to call inpart ? I don't know what you are trying
to do, but part hacking is rarely necessary. If you just want the first
and second arguments of expr, why not first(expr) and second(expr) ?

FWIW

Robert Dodier