Why is *print-circle* set to T by default? WAS: grinding, etc.
Subject: Why is *print-circle* set to T by default? WAS: grinding, etc.
From: Raymond Toy
Date: Wed, 09 Feb 2011 10:43:40 -0500
On 2/9/11 10:01 AM, Stavros Macrakis wrote:
> I don't know why *print-circle* is set to T by default in Maxima -- it
> makes human reading of printed sexpressions much harder, even when
> there *are* repeated subexpressions -- see examples below.
> Admittedly this makes life easier for sophisticated users who want to
> look at assume's data structures (often found in symbol property
> lists), but it makes this more complicated for the beginner who simply
> wants to see what the Lisp representation of a Maxima expression is.
It was changed sometime in 2009 by Robert. I guess he was working with
the assume database which apparently has circular structures.
I normally just turn it off now (by hand) when I print the Lisp rep. I
ought to be able to read them, but I find it rather hard to read.
Ray
>
> You should probably set *print-circle* to nil, unless you're planning
> to be creating circular expressions (which are almost never
> appropriate in Maxima expressions).
>
> (x+1)^3 <<< Maxima linear form
>
> ((MEXPT SIMP) ((MPLUS SIMP) 1 $X) 3) <<< Lisp print with
> *print-circle* = NIL
>
> ((MEXPT . #0=(SIMP)) ((MPLUS . #0#) 1 $X) 3) <<< Lisp print with
> *print-circle* = T
>
> rat((x+1)^3)
>
> ((MRAT SIMP ($X) (#:X34080)) (#:X34080 3 1 2 3 1 3 0 1) . 1)
>
> ((MRAT SIMP ($X) (#0=#:X34080)) (#0# 3 1 2 3 1 3 0 1) . 1)
>
> 3*cos(x)^2*sin(x)-sin(x)^3
>
> ((MPLUS SIMP)
> ((MTIMES SIMP) 3 ((MEXPT SIMP) ((%COS SIMP) $X) 2) ((%SIN SIMP) $X))
> ((MTIMES SIMP) -1 ((MEXPT SIMP) ((%SIN SIMP) $X) 3)))
>
> ((MPLUS . #0=(SIMP))
> (#1=(MTIMES . #0#) 3 (#2=(MEXPT . #0#) ((%COS . #3=(SIMP)) $X) 2)
> #4=((%SIN . #3#) $X))
> (#1# -1 (#2# #4# 3)))
>
> The main reason to use *print-circle* in Maxima is probably when
> looking at the property lists of atoms which have 'assume' (+LABS)
> properties, which use a circular Lisp representation. It's
> unfortunate that Common Lisp doesn't support some version of
> *print-circle* which does not use the #0= syntax for common
> subexpressions which are *not* circular (I know, it's slightly harder
> to implement, but...).
>
> -s
>
> On Wed, Feb 9, 2011 at 04:34, Michel Talon <talon at lpthe.jussieu.fr
> <mailto: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?
>
> Thanks a lot
>
> --
> Michel Talon
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu <mailto:Maxima at math.utexas.edu>
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima