Ralf Hemmecke wrote:
> 
> > BTW: We have to handle scripted symbols in Symbol, because this
> > is the only place where we can reliably distinguish scripted
> > symbols from some weird Lisp s-expression which is similar
> > to our representation of scripted symbols.
> 
> Hmmm.... in OutputForm it says...
> 
>         scripts : (%, List %) -> %
>             ++ \spad{scripts(f, [sub, super, presuper, presub])}
>             ++  creates a form for f with scripts on all 4 corners.
> 
> >From which I would never dare to hand that function a list with less
> than 4 elements.
> 
> (But your new implementation seems to rely on that feature.)
> 
> In fact, looking at the implementation, it does the right job when
> called with less elements. The docstring should be improved.

Yes.  Maybe:

           ++ \spad{scripts(f, l)} where l is
           ++ \spad{[sub, super, presuper, presub]} creates a form
           ++ for f with scripts on all 4 corners.  If l has less
           ++ than 4 elements corresponding script is absent.
 

> Or maybe we rather introduce
> 
>   scripts(f, sub)
>   scripts(f, sub, super)
>   scripts(f, sub, super, presuper)
>   scripts(f, sub, super, presuper, presub)

No.  That would be clumsy.

> In general I don't like if List is misused. Here one can call that
> function with a list that has more than 4 elements. The docstring says
> nothing whether such a call will succeed or yield an error. :-(
> 
> Your implementation of coerce: % -> OutputFom in Symbol
> https://github.com/fricas/fricas/blob/master/src/algebra/symbol.spad#L101
> has something like this...
> 
>     rsl : List(L) := [ss.presub, ss.presup, ss.sup, ss.sub]
>     for si in rsl repeat
>          empty?(sl) and empty?(si) => "iterate"
>          se :=
>              #si = 1 => first(si)
>              commaSeparate(si)
>          sl := cons(se, sl)
>     x0 := outputForm(name(x) pretend Symbol)
>     x1 :=
>          #sl = 1 => sub(x0, first(sl))
>          scripts(x0, sl)
> 
> but wouldn't it be simpler to have
> 
>     rsl : List(L) := [ss.sub, ss.sup, ss.presup, ss.presub]
>     sl: List L := [commaSeparate z for z in rsl | not empty? z
>     x0 := outputForm(name(x) pretend Symbol)
>     x1 := scripts(x0, sl)
> 
> There is no need to single out the one-element cases here, because
> OutputForm must handle something like commaSeparate([x]) correctly,
> anyway. And (scripts$OutputForm)(a, l) is equivalent to
> sub(a, first l) if the l has only one element.

That would not do: we can only skip scripts at the end.  Skipping
script in the middle would move later script to different position.
And we have to skip scripts because otherwise we would get ugly
output.  We can omit test for '#sl = 1'.  I special case
'#si = 1' because this leads to different OutputForm and I wanted
maximal compatibility with old code (which did the same).

-- 
                              Waldek Hebisch
[email protected] 

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to