Using lisp code to the max

I want to use (make-array '(4 3 8))in maxima, which basically creates a multi-disk matrix, since I cannot find an API for creating multi-disk matrices, including array(name,d1,d2...dm).

I can execute it with :lisp (make-array '(4 3 8)), but I don’t know how I can label it somehow like

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

I also want to know if lisp code can be used inside maximum functions. Any help should be greatly appreciated.

+4
source share
2 answers

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

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

Lisp Maxima. Lisp. Lisp $foo, Maxima it foo; Lisp it foo, Maxima ?foo. :.

:lisp (defun $foo (x) ...)

f(x) := print (foo (x));

, Maxima - ... , - .

+5

make_array :

(%i18) make_array(fixnum,4,3,8);
(%o18) {Array:  #3A(((0 0 0 0 0 0 0 0) (0 0 0 0 0 0 0 0) (0 0 0 0 0 0 0 0))
    ((0 0 0 0 0 0 0 0) (0 0 0 0 0 0 0 0) (0 0 0 0 0 0 0 0))
    ((0 0 0 0 0 0 0 0) (0 0 0 0 0 0 0 0) (0 0 0 0 0 0 0 0))
    ((0 0 0 0 0 0 0 0) (0 0 0 0 0 0 0 0) (0 0 0 0 0 0 0 0)))}

Lisp :

(%i21) :lisp (msetq $foo (make-array '(4 3 8)));

#3A(((NIL NIL NIL NIL NIL NIL NIL NIL)
     (NIL NIL NIL NIL NIL NIL NIL NIL)
     (NIL NIL NIL NIL NIL NIL NIL NIL))
    ((NIL NIL NIL NIL NIL NIL NIL NIL)
     (NIL NIL NIL NIL NIL NIL NIL NIL)
     (NIL NIL NIL NIL NIL NIL NIL NIL))
    ((NIL NIL NIL NIL NIL NIL NIL NIL)
     (NIL NIL NIL NIL NIL NIL NIL NIL)
     (NIL NIL NIL NIL NIL NIL NIL NIL))
    ((NIL NIL NIL NIL NIL NIL NIL NIL)
     (NIL NIL NIL NIL NIL NIL NIL NIL)
     (NIL NIL NIL NIL NIL NIL NIL NIL)))
(%i21) foo;
(%o21) {Array:  #3A(((NIL NIL NIL NIL NIL NIL NIL NIL)
     (NIL NIL NIL NIL NIL NIL NIL NIL)
     (NIL NIL NIL NIL NIL NIL NIL NIL))
    ((NIL NIL NIL NIL NIL NIL NIL NIL)
     (NIL NIL NIL NIL NIL NIL NIL NIL)
     (NIL NIL NIL NIL NIL NIL NIL NIL))
    ((NIL NIL NIL NIL NIL NIL NIL NIL)
     (NIL NIL NIL NIL NIL NIL NIL NIL)
     (NIL NIL NIL NIL NIL NIL NIL NIL))
    ((NIL NIL NIL NIL NIL NIL NIL NIL)
     (NIL NIL NIL NIL NIL NIL NIL NIL)
     (NIL NIL NIL NIL NIL NIL NIL NIL)))}
, array, , . , . Wikibooks :
(%i22) array(A,2,2,2);
(%o22)                                 A
(%i23) arrayinfo(A);
(%o23)                     [declared, 3, [2, 2, 2]]
(%i24) A[0,1,2]: 2;
(%o24)                                 2
(%i25) listarray(A);
(%o25) [#####, #####, #####, #####, #####, 2, #####, #####, #####, #####, 
#####, #####, #####, #####, #####, #####, #####, #####, #####, #####, #####, 
#####, #####, #####, #####, #####, #####]

Maxima , , , Wikibooks : " / - [...]"

+2

Source: https://habr.com/ru/post/1530012/


All Articles