I found a bug in unparse:
-----------------------------------------------------------------------
(1) -> ex := (1..3)::Segment FRAC INT::INFORM
(1) (($elt (Segment (Fraction (Integer))) SEGMENT) 1 3)
Type:
InputForm
(2) -> interpret ex
(2) 1..3
Type:
Segment(Fraction(Integer))
(3) -> unparse ex
(3) "1..3$Segment(Fraction(Integer))"
Type:
String
(4) -> 1..3$Segment(Fraction(Integer))
There are no library operations named elt having 0 argument(s)
though there are 46 exposed operation(s) and 5 unexposed
operation(s) having a different number of arguments. Use HyperDoc
Browse, or issue
)what op elt
to learn what operations contain " elt " in their names, or issue
)display op elt
to learn more about the available operations.
Cannot find application of object of type Domain .
-----------------------------------------------------------------------
The correct result of unparse would be
(3) -> unparse ex
(3) "(1..3)$Segment(Fraction(Integer))"
I believe the bug is in form2String1, format.boot, where the function
SEGMENT is given special treatment:
--------------------------------------------------------------------------
form2String1 u ==
...
op = 'COLLECT => formCollect2String argl
op = 'construct =>
concat(lbrkSch(),
tuple2String [form2String1 x for x in argl],rbrkSch())
op = "SEGMENT" =>
null argl => '".."
lo := form2String1 first argl
argl := rest argl
(null argl) or null (first argl) => [lo, '".."]
[lo, '"..", form2String1 first argl]
op = "MATRIX" => matrix2String argl
u1 is ["ROOT", arg1] =>
concat("sqrt(", appOrParen(arg1),")")
u1 is ["ROOT", arg1, arg2] =>
concat("nthRoot(", appOrParen(arg1),",",appOrParen(arg2),")")
--concat(appOrParen(arg1), '"^", appOrParen(["OVER",1,arg2]))
u1 is ["$elt", t, f] =>
concat(form2String1 f, '"$", form2String1 t)
#argl = 2 and (isBinaryInfix op or op = "::" or op = '"::"_
or op = "@" or op = '"@" or op = "pretend" or op = '"pretend"_
or op = "OVER" or op = '"OVER") =>
binop2String [op,:argl]
application2String(op,[form2String1 x for x in argl], u1)
--------------------------------------------------------------------------
I guess there are two ways to fix this:
a) remove the special treatment of SEGMENT.
b) introduce parens
I prefer a), and I think that this should be done for most of the
special cases above. The only worry is that it seems that OutputForm
and friends also use these special names, but they do not seem to use
form2String1 -- I did )tr form2String1
Martin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en
-~----------~----~----~----~------~----~------~--~---