On Monday, January 19, 2015 at 8:22:15 AM UTC-8, Dima Pasechnik wrote:
>
> On 2015-01-19, Julien Puydt <julien...@laposte.net <javascript:>> wrote: 
> > Hi, 
> > 
> > I wanted to play with maxima-in-ecl to understand how it works, but 
> > failed: from reading sage's sources I thought I was supposed to use a 
> > MEVAL function, but it failed. Here is what I did: 
> > 
> > jpuydt@cauchy:~/sage-6.4.1$ ./sage -ecl 
> > ECL (Embeddable Common-Lisp) 13.5.1 (git:UNKNOWN) 
> > Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya 
> > Copyright (C) 1993 Giuseppe Attardi 
> > Copyright (C) 2000 Juan J. Garcia-Ripoll 
> > ECL is free software, and you are welcome to redistribute it 
> > under certain conditions; see file 'Copyright' for details. 
> > Type :h for Help. 
> > Top level. 
> > > (require 'maxima) 
> > 
> > ;;; Loading #P"/home/jpuydt/sage-6.4.1/local/lib/ecl/maxima.fas" 
> > ;;; Loading #P"/home/jpuydt/sage-6.4.1/local/lib/ecl/sb-bsd-sockets.fas" 
> > ;;; Loading #P"/home/jpuydt/sage-6.4.1/local/lib/ecl/sockets.fas" 
> > ("SB-BSD-SOCKETS" "SOCKETS" "MAXIMA") 
>
> here you need to go into the right namespace, or whatever it is called: 
>
> > (in-package :maxima) 
>
> > > (meval "2+2") 
>
> but I don't know how to compute 2+2, still :-)) 
>
>  
The maxima parser is available via the reader macro. Normally it will 
produce a form that evaluates too, but if you quote it, you can prevent 
that from happening:

> (require `maxima)
[...]
> (in-package :maxima)
MAXIMA> #$2+2$ 

4
MAXIMA> '#$x+5$

(MEVAL* '((MPLUS) $X 5))
MAXIMA> (meval '((mplus) 2 2))

4

See the maxima source for the (subtle and as far as I can see largely 
irrelevant) differences between meval and meval*.

The key thing to realize is that the maxima language gets parsed into lisp 
expressions (that's what they are for!) and that you can enter those 
expressions yourself once you've figured out what structure is expected: 
it's always:

( (<operator> [<flag1> <flag2> .... <flag_k>) <arg1> ... <arg_n>)

so it's almost lisp syntax, except that the operator slot is *itself* a 
list too to allow for flags marking properties of the expression. This 
feature doesn't get used much, and the "SIMP" flags hardly seem to make any 
difference in practice when you enter an expression.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to