Structs and display2d



Display with display2d=false, string, and grind should produce output that
is suitable for input to Maxima. * In addition*, 'grind' tries to indent
nicely (pretty-print) -- see below.  The documentation for display2d should
probably be improved to clarify this.

(%i13) linel:20$
(%i14) string(expr);
(%o14) "if a = 23 then foo:bar elseif a = 24 then foo:2*bar elseif a = -3
then print(7) else 9"
(%i15) grind(expr);
if a = 23
    then foo:bar
    elseif a = 24
    then foo:2*bar
    elseif a = -3
    then print(7)
    else 9$
(%o15) done
(%i16) expr;
(%o16) if a=23 then foo:bar elseif a=24 then foo:2*bar elseif a=-3 then
print(7) else 9

On Sun, Dec 2, 2012 at 1:37 PM, Volker van Nek <volkervannek at gmail.com>wrote:

> Thanks for enlightment.
>
> As you write there should be a difference between display2d=false and
> grind. The documentation says
>
> 1. When `display2d' is `false', the console display is a string
> (1-dimensional) form rather than a display (2-dimensional) form.
>
> 2. The function `grind' prints <expr> to the console in a form
> suitable for input to Maxima.
>
> Following this only grind(struct) should result in what I get with
> display2d=false at the moment while display2d=false shouldn't hide the
> field names which contain useful information.
>
> For getting a working test file where answer and input must be the
> same I will wrap the structs in a grind.
>
> Thanks
> Volker
>
>
> 2012/12/2 Robert Dodier <robert.dodier at gmail.com>:
> > On 2012-12-02, Volker van Nek <volkervannek at gmail.com> wrote:
> >
> >> Structs are displayd quite differently depending on display2d. Is this
> a bug?
> >
> > Well, at present the display2d=false display of structures is a readable
> > representation, so if you input that stuff, you get the same object. The
> > field names are displayed when display2d=true as a convenience, but
> > they're not necessary for input -- as it stands, they can't be part of
> > the input, because then something like foo=bar where foo is a field name
> > is ambiguous -- does it mean value foo for field bar, or value foo=bar
> > (an equation) for foo or any other field?
> >
> > That said, maybe only grind needs to output a readable representation --
> > maybe display2d=false need only be 1-dimensional. I suppose the 1-d
> > display code for structures could attempt to distinguish grind from
> > display2d=false.
> >
> > best
> >
> > Robert Dodier
> >
> > _______________________________________________
> > Maxima mailing list
> > 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
>