Any clues about whats going on here ?
-----------
(%i1) mta(expr,v) := makelist(expr,inpart(v,1),1,inpart(v,2))$
(%i2) mtb(expr,v) := create_list(expr,inpart(v,1),1,inpart(v,2))$
(%i3) mta(x,[1,2]);
(%o3) [x,x]
(%i4) mtb(x,[1,2]);
(($INPART) $V 1) not a symbol
#0: mtb(expr=x,v=[1,2])
-- an error. To debug this try debugmode(true);
-----------
I prefer to use create_list rather than makelist because it
is at least 10 times faster on some tests I ran.
This works:
mtc(expr,v) := apply('create_list, [expr,inpart(v,1),1,inpart(v,2)])$
mtc(x,[x,2]);
(%o21) [1,2]
But I can't use mtc because it fails on other cases,
eg. with functions with a certain loop construction,
(I tried to re-write the loop every way I could think of!):
(%i2) fn(n) := while n > 0 do n:n-1$
(%i3) mta(fn(x),[x,2]);
Maxima was unable to evaluate the predicate:
x > 0
#0: fn(n=x)
-- an error. To debug this try debugmode(true);
mtb(fn(x),[x,2]) and mtc(fn(x),[x,2]) give the same failure.
However this works:
(%i6) create_list(fn(i),i,1,2);
(%o6) [done,done]
And this is the result for some builtin function, showing that
there is something particular about the function fn that causes
the failure.
(%i7) mta(cos(x),[x,2]);
(%o7) [cos(x),cos(x)]
This fails:
(%i8) mtb(cos(x),[x,2]);
(($INPART (4 intdig.mac SRC $MTB 4)) $V 1) not a symbol
#0: mtb(expr=cos(x),v=[x,2])(intdig.mac line 4)
-- an error. To debug this try debugmode(true);
This works:
(%i9) mtc(cos(x),[x,2]);
(%o9) [cos(1),cos(2)]
Thanks,
John