I've never used CLISP, but here's what you should
consider doing.
1. the function tl is in the package mma.
try typing (in-package :mma) first.
2. You probably just want to parse stuff in the
file, and so using the function ps , actually
(mma::ps) is more appropriate.
for example,
(in-package :mma)
(ps (open "test.ma") );;; result should go to standard output.
Something is wrong, though.
I'll try to figure this out after my class today..
;; the file testin.m starts with your example DeleteVertex[Graph....
(ps (open "testin.m"))
;; some garbage, omitted here..... then
nil
(Module
(List (Set nodes v) (Set flags f) (Set numbers nr) (Set edges e) (Set startnodes stnodes) (Set
tailnodes endnodes)
i tmpedge tmpg)
(CompoundExpression (Set edge (Part nodes nodenr))
(While (Unequal edge 0)
(CompoundExpression (Set tmpedge edge) (Set edge (Part edges edge))
(Set (Part edges tmpedge) -1)
(Set (List (Part startnodes tmpedge) (Part tailnodes
tmpedge))
(List -1 -1))))
(Set (List (Part nodes nodenr) (Part flags nodenr) (Part numbers nodenr)) (List
-1 -1 -1))
(Set tmpg (Graph nodes flags numbers edges startnodes tailnodes))
(For (Set i 1) (LessEqual i (Length edges)) (Increment i)
(If (Equal (Part tailnodes i) nodenr) (Set tmpg (DeleteEdge tmpg i))))
Null))
Daniel Martins wrote:
>
> I tried for the last 2 days and this message is possibly a declaration
> of stupidity, but the fact is that I could not do the job as I wanted.
Thanks for trying, but next time ask sooner!
>
> In the end of this message I send an extract of a clisp session to
> load MockMMA and a extract of one of the files I want to
> translate.
>
> >>>>> "Richard" == Richard Fateman <fateman@cs.berkeley.edu> writes:
>
> Richard> 1. Change all Mathematica forms to FullForm. This can be
> Richard> done easily in Mathematica. Thus x+y becomes Plus[x,y]
> Richard> etc.
>
> Richard> 2. Print out all such forms in a lisp-like form. Thus
> Richard> Plus[x,y] is printed as (Plus x y).
>
> Sorry, but how can I do this "easily" using Mathematica? I need to add
> \\FullForm at the end of every line? I could not see a way of
> translating all the file to FullForm.
You can do this with expressions, so I assume that if you can print
a function definition in mathematica somehow, you can fullform it too.
There is a way of changing the output of every line by wrapping it
in some function. I forget how.
>
> Richard> 3. Read the resulting file into lisp.
> Richard> Using an appropriate function like subst change Plus to
> Richard> (mplus) Times to (mtimes) etc.
>
> Do you have a list of these changes? With this list, I can provide a
> Perl script to do this job.
It would be trivial to do it in lisp, and then wouldn't require you
to run any other program. I know that perl programmers don't believe
that anything is easier than perl. but lisp is easier here.
I don't offhand have a list of all the changes, sorry.
>
> Richard> If you actually don't have a Mathematica system, steps 1
> Richard> and 2 can be done entirely in lisp by using my MockMMA
> Richard> parser (written in Lisp), at least for Mathematica 2.0
> Richard> syntax.
>
> BTW I tried to load the mma1.6 in clisp without success. I followed
> the instruction at davorpatch which accompanies mma1.6.tar.gz
see comments above.
>
> *******************CLISP session Begin *************************
>
> [1]> (load "init2")
> ;; Loading file /home/daniel/Mathematica/mma1.6/init2.fas ...
> ;; Loading of file /home/daniel/Mathematica/mma1.6/init2.fas is finished.
> T
> [2]> (tl)
>
> *** - EVAL: the function TL is undefined
> 1. Break [3]>
>
> *******************CLISP session End *************************
>
> At last, here is an extract of one of the files I want to
> translate. All files have the same pattern but have different modules
> and definitions (of course).
>
> ******************* Mathematica file Begin *************************
>
> BeginPackage["MyPackage`"]
>
> MyPackage::usage="Do what I want"
>
> Begin["`Private`"]
>
> (* lots of definitions *)
>
> Edges[Graph[v_,f_,nr_,e_,stnodes_,endnodes_ ]]:= e
>
> (* lots of modules *)
>
> DeleteVertex[Graph[v_,f_,nr_,e_,stnodes_,endnodes_ ],nodenr_Integer]:=
> Module[{nodes = v,flags=f,numbers=nr,edges=e,
> startnodes=stnodes,tailnodes=endnodes,i,tmpedge,tmpg},
> edge = nodes[[nodenr]];
> While[edge!=0,tmpedge= edge;
> edge=edges[[edge]];
> edges[[tmpedge]]=-1;
> {startnodes[[tmpedge]],tailnodes[[tmpedge]]}={-1,-1}
> ]; (* end while *)
> {nodes[[nodenr]],flags[[nodenr]],numbers[[nodenr]]} = {-1,-1,-1};
> tmpg = Graph[nodes,flags,numbers,edges,startnodes,tailnodes];
> For[i=1,i<=Length[edges],i++,
> If[tailnodes[[i]]==nodenr,
>
> tmpg = DeleteEdge[tmpg,i]
>
> ] (* end if *)
> ]; (* end for *)
> tmpg
> ] (* end module *)
>
> End[ ]
> EndPackage[ ]
>
> ******************* Mathematica file Begin *************************
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima