create Maxima list from multiple return values of a Lispfunction
Subject: create Maxima list from multiple return values of a Lispfunction
From: Edwin Woollett
Date: Thu, 16 Jun 2011 14:16:24 -0700
On June 16, 2011, Leo Butler wrote
---------------------------------
>> gcl:rename_file returns three values.
>>
>> How can I turn these into a Maxima list?
>> -----------------------------
>> (%i1) :lisp (rename-file "foo.txt" "bar.txt")
>> #pbar.txt
>> #pC:/work2/foo.txt
>> #pC:/work2/bar.txt
> :lisp (defmfun $rename_file (from to) (append '((mlist simp))
> (multiple-value-list (rename-file from to))))
> (%i1) rename_file("/tmp/foo.txt","/tmp/bar.txt");
> (%o1) [/tmp/bar.txt, /tmp/foo.txt, /tmp/bar.txt]
------------------
When I try this using :lisp I get ok result,
but if I use to_lisp() and try to use the
same definition with a different name
I get a Lisp error.
---------------------------------------
(%i1) :lisp (probe-file "bar.txt")
#pC:/work2/bar.txt
(%i1) :lisp (defmfun $rename_file (from to) (append '((mlist simp))
(multiple-value-list (rename-file from to))))
$RENAME_FILE
(%i1) rename_file("bar.txt","foo.txt");
(%o1) [#pfoo.txt, #pC:/work2/bar.txt, #pC:/work2/foo.txt]
(%i2) to_lisp();
Type (to-maxima) to restart, ($quit) to quit Maxima.
/* here I try to call the Maxima function rename1_file but
the name is not accepted */
MAXIMA> (defmfun $rename1_file (from to)
(append '((mlist simp)) (multiple-value-list (rename-file from to))))
$RENAME_FILE
/* here I try to call the Maxima function
rename_file_a, and the name appears to
be accepted, but use then leads to error
messages. */
MAXIMA> (defmfun $rename_file_a (from to)
(append '((mlist simp)) (multiple-value-list (rename-file from to))))
$RENAME_FILE_A
MAXIMA> (probe-file "foo.txt")
#p"C:/work2/foo.txt"
MAXIMA> rename_file_a ("foo.txt","bar.txt")
Maxima encountered a Lisp error:
Error in EVAL [or a callee]: The variable RENAME_FILE_A is unbound.
Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.
MAXIMA>
Maxima encountered a Lisp error:
Error in READ [or a callee]: A comma has appeared out of a backquote.
Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.
MAXIMA>
"bar.txt"
MAXIMA>
---------------------
Ted