output in lisp form
- To: mathgroup at yoda.physics.unc.edu
- Subject: output in lisp form
- From: Frederic Udina <udina at upf.es>
- Date: Wed, 3 Feb 93 12:25:22 WET
hello
I need to output my number lists in a format readable by lisp.
I have developped a dirty solution as listed below.
It remains a problem, my file contains " and \ characters.
Has someone worked out a better tool to do this task?
If not, I must work my solution to the end...
Thanks
Frederic Udina
Facultat de Ciencies Economiques
Universitat Pompeu Fabra
Balmes 132
08008 Barcelona
SPAIN
voice: 34 - 3 - 484 97 56
fax: 34 - 3 - 484 97 46
e-mail: udina at upf.es
appleLink: spa0172
(*a dirty attempt to transfer data from mma to lisp*)
Clear[LispForm];
LispForm[x_List]:=Block[{strlist,str},
strlist = LispForm /@ x;
str = StringJoin @@ strlist;
StringJoin["(list ", str, ") "]];
LispForm[x_?NumberQ]:=StringJoin[ToString[FortranForm[x]]," "];
(*If you do
LispForm[some list of numbers] >> somefile.lsp
you will get
"(list (list -1.2 0 ) (list -1.1 0 ) (list -1. 1.2326e-32 ) (list -0.9 0.01 )\
(list -0.8 0.04 ) (list -0.7 0.09 ) (list -0.6 0.16 ) (list -0.5 0.25 )\
(list -0.4 0.36 ) (list -0.3 0.49 ) (list -0.2 0.64 ) (list -0.1 0.81 )\
(list -2.77556e-17 1. ) (list 0.1 0.81 ) (list 0.2 0.64 ) (list 0.3 0.49 )\
(list 0.4 0.36 ) (list 0.5 0.25 ) (list 0.6 0.16 ) (list 0.7 0.09 ) (list\
0.8 0.04 ) (list 0.9 0.01 ) (list 1. 1.2326e-32 ) (list 1.1 0 ) (list 1.2 0\
) ) "
in your file
I don't mind in this moment how to suppress the ".
*)