Martin R wrote:
> attached a patch. Curiously, the InputForm of products and sums gets rid
> of subscripted symbols automagically...
Well, you use dummy variables in input form. Scripted symbols
only appear in names corresponding to dummies. So in effect
you drop original names of variables, replacing them by
dummies. ATM I am not sure if this matters.
>
> @@ -470,6 +470,19 @@ OutputForm() : SetCategory with
> outputForm s ==
> sform concat(quote()$Character, concat(s, quote()$Character))
>
> + convert(a: %): InputForm ==
> + b: SExpression := a pretend SExpression
> + if atom?(b)$SExpression then
> + if string?(b)$SExpression then
> + c: String := string(b)$SExpression
> + l: Integer := maxIndex(c)
> + if l >= 2 and c.1 = c.l and c.1 = quote()$Character then
> + d: String := c.(2..(maxIndex c)-1)
> + b: SExpression := convert(d)$SExpression
> + return convert(b)$InputForm
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AFAICS this has undesirable effect on symbols. Namely, symbols
are supposed to be evaluated:
(1) -> if1 := (x::Symbol)::InputForm
(1) x
Type: InputForm
(2) -> x := 5
(2) 5
Type: PositiveInteger
(3) -> interpret(if1)
(3) 5
Type: PositiveInteger
However, it seem desirable to preserve names of symbols, and with
the code above name (more precisely subscripts) can change:
(31) -> z[y]
(31) z
y
Type: Symbol
(32) -> if2 := (z[y])::InputForm
(32)
(script z
(construct (construct y) (construct) (construct) (construct) (construct)))
Type: InputForm
(33) -> y := 5
(33) 5
Type: PositiveInteger
(34) -> interpret(if2)
(34) z
5
Type: Symbol
Also for consistency with other cases we should prevent 'y' from
evaluation above.
BTW: This ilustrates that InputForm (or rather 'convert') is not
well defined. Namely, for expressions it is natural to expect
that InputForm can be evaluated and value will depend on
variables. For domains which represent values (most of
FriCAS domains) it is natural that InputForm reconstructs
the value. But there are borderline cases. In fact, it
would make sense to have two different 'convert'-s: one
which is intended to pick values from environment and
the other which should reconstruct value exactly. But
this is separate topic...
--
Waldek Hebisch
--
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 https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.