title: coding in maxima language vs lisp
body: <p>I just thought of writing some function similar to <code>Mathematica</code>'s <a href="http://reference.wolfram.com/mathematica/ref/Partition.html" rel="nofollow">partition function</a> with passing option in maxima as,</p>
  
  <pre><code>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)&gt;=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));
  </code></pre>
  
  <blockquote>
    <p><code>Usage</code>:listpartitionpad([a,b,c,d,e,f,g],3,3,x); => [[a,b,c],[d,e,f],[g,x,x]]</p>
  </blockquote>
  
  <p>Now allof the list manipulation functions are coded in lisp as I checked. </p>
  
  <p>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 </p>
  
  <p><code>:lisp(time(loop repeat 1000000))</code> </p>
  
  <pre><code>real time       :      0.850 secs
  run-gbc time    :      0.540 secs
  child run time  :      0.000 secs
  gbc time        :      0.310 secs
  </code></pre>
  
  <p>In case of another maxima based approach,</p>
  
  <pre><code>block([],for i:1 thru 1000000 do []);
  </code></pre>
  
  <blockquote>
    <p>Evaluation took 5.7700 seconds (5.7700 elapsed)</p>
  </blockquote>
  
  <p>And this difference grows exponentially as <code>i</code> grows.</p>
  
  <p>Is this the reason all list manipulations are coded in lisp ?</p>