On 2/9/11, Michel Talon <talon at lpthe.jussieu.fr> wrote:
> Hello,
>
> i am trying to write a grind variant to convert expressions so that they can
> be embedded in Gnu GMP programs. In the course of doing that, i have, of
> course, consulted forta.lisp, grind.lisp and mactex.lisp, but i see that
> some expressions are of the following form:
> niobe% maxima
> (%i1) x:y*(z+t^2)$
>
> (%i2) :lisp $X
>
> ((MTIMES . #1=(SIMP)) $Y ((MPLUS . #1#) ((MEXPT . #1#) $T 2) $Z))
>
> I am puzzled by the #1=(SIMP) ... #1#
> I suppose that #1 has to be replaced by SIMP but would someone be kind
> enough to explain how this syntax can be understood from lisp?
>
> Well, grind.lisp is not the most obvious thing to understand, i see
> that prof Fateman has lifted some parts to texmacs.lisp and added some
> comments, but does someone know what msize is supposed to do? I am puzzled
> by such stuff:
> (%i2) :lisp (msize $X nil nil 'mparen 'mparen)
>
> (9 (1 y) (8 (3 * ( z) (5 (2 + t) (3 ^ 2 )))))
>
> From Fateman's comments i see that in
> defun msize (x l r lop rop)
> l and r are supposed to be stuff at the left and right of x, while
> lop and rop are left and right "parenthesis", here true parenthesis,
> but if somebody remembers what is this left and right stuff, and what
> these numbers 9 8 etc. mean, i would be grateful.
>
> By the way, at first sight, 9 is the total number of characters in the
> expansion of x, in (1 y) y has 1 character, in (8 ( ...)) there are 8
> characters after the *, but at (3 * i don't understand precisely ...
>
> Of course i suppose the aim is to be able to cut long lines by counting
> characters but how exactly?
Writing a custom grind function ex nihilo probably isn't worth the trouble.
What are you trying to do?
Probably it's easier to adapt some existing code.
Take a look at the f90 function.
The output is somewhat closer to C than Fortran.
HTH
Robert Dodier