I want to create a function in Maxima
similar to ConstantArray in Mathematica
. So I tried putting a wrapper around make-array
but make_array(fixnum,2,3,4)
takes last arguments as a sequence of parameters rather than a list while if one calls ConstantArray(a,b,c,d..)
with variable number of arguments than I cannot pass it to make-array without putting it all as list.
To get around the problem of extracting elements from list passed as parameter and putting in make-array function, I tried,
constantarray((l)):=block([eq:'make_array(fixnum)],
map(lambda([x],eq:endcons(x,eq)),l),eq);
which on calling
constantarray([1,2,3,5,3]);
returns
make_array(fixnum,1,2,3,5,3)
This function executes well if I copy this output, paste it on console and run it as it returns me the Lisp array [1,2,3,5,3]
.
I have tried evaluating it using ''%
& ev(constantarray(1,2,3,5,3),nouns)
etc but its just not working. I want to know if someone knows how to force this evaluation or I am doing something not possible.