lispcommon-lispmaximacomputer-algebra-systems

Using lisp code in maxima


I want to use (make-array '(4 3 8)) in maxima which is basically to generate multi-d matrix as I am not able to find API to create multi-d matrices including with array(name,d1,d2...dm).

I can execute it using :lisp (make-array '(4 3 8)) but I don't know how I can label it as something like,

arr: :lisp(make-array '(4 3 8))

I also want to know if it is possible to use lisp code inside maxima functions. Any sort of help shall be highly regarded.


Solution

  • To create a named array in Lisp code just exactly the same as array(name, d1, d2, ..., dm), write:

    (mfuncall '$array name d1 d2 ... dm)
    

    You can't include Lisp code directly in Maxima functions. But you can call Lisp functions. If the lisp function is named $foo, then in Maxima it's foo; if in Lisp it's foo, then in Maxima it's ?foo. E.g.:

    :lisp (defun $foo (x) ...)
    
    f(x) := print (foo (x));
    

    By the way, Maxima's treatment of arrays is still a mess ... maybe someday we'll clean it up.