I just thought of writing some function similar to Mathematica
's partition function with passing option in maxima as,
listpartitionpad(l,n,k,d):= block([temp:[],gap,newl,ntemp:[]],
newl:apply(create_listpad,flatten([n,k,d,l])),
map(lambda([x],if(length(newl)>=x+n-1 and is(unique[x]#[d]))then temp:cons(part(newl,makelist(i,i,x,x+n-1)),temp)
else temp:cons(part(newl,makelist(s,s,x,length(newl))),temp)),makelist(i,i,1,length(newl),k)),
ntemp:sublist(temp,lambda([x],is(length(x)=n))),reverse(ntemp));
Usage
:listpartitionpad([a,b,c,d,e,f,g],3,3,x); => [[a,b,c],[d,e,f],[g,x,x]]
Now allof the list manipulation functions are coded in lisp as I checked.
My question is that is it fine that I could code any such function in maxima language rather than in lisp or it will give me some performance issue or something else I should know that I don't yet. I ran a simple test
:lisp(time(loop repeat 1000000))
real time : 0.850 secs
run-gbc time : 0.540 secs
child run time : 0.000 secs
gbc time : 0.310 secs
In case of another maxima based approach,
block([],for i:1 thru 1000000 do []);
Evaluation took 5.7700 seconds (5.7700 elapsed)
And this difference grows exponentially as i
grows.
Is this the reason all list manipulations are coded in lisp ?