I think this is a strange problem.
Consider the following code which is a simplified and reduced version
of some larger piece that I am currently working on:
-- file: BadCode.spad
)abbrev domain BAD BadCode
BadCode(A:Monoid): with
coerce: %->OutputForm
== add
Rep == List A
rep(x:%):Rep == x pretend Rep
per(x:Rep):% == x pretend %
coerce(x:%):OutputForm ==
r:=rep(x)
--output("#r=",#r::OutputForm)$OutputPackage
if empty? r then coerce(0$InputForm)
else if #r=1 then
s:=first r
if s=1 then
coerce(1$InputForm)
else
coerce(s)
else coerce(convert("more")@InputForm)
--
(1) -> )co BadCode.spad
Compiling FriCAS source code from file /home/wspage/BadCode.spad
using old system compiler.
BAD abbreviates domain BadCode
...
BadCode is already explicitly exposed in frame frame1
BadCode will be automatically loaded when needed from
/home/wspage/BAD.NRLIB/BAD
(1) -> ([] pretend BAD(Integer))
(1) 0
Type: BadCode(Integer)
(2) -> ([1] pretend BAD(Integer))
(2) 1
Type: BadCode(Integer)
(3) -> ([2] pretend BAD(Integer))
(3) 2
Type: BadCode(Integer)
(4) -> ([1,2] pretend BAD(Integer))
(4) 1
Type: BadCode(Integer)
--
Notice the result in (4) above. I expected to see the output "more".
Now remove the commenting from the line:
output("#r=",#r::OutputForm)$OutputPackage
and try again. This line is intended for debugging and is not expected
to have any affect on the final result.
(5) -> )co BadCode.spad
Compiling FriCAS source code from file /home/wspage/BadCode.spad
using old system compiler.
BAD abbreviates domain BadCode
...
BadCode is already explicitly exposed in frame frame1
BadCode will be automatically loaded when needed from
/home/wspage/BAD.NRLIB/BAD
(5) -> ([] pretend BAD(Integer))
#r= 0
(5) 0
Type: BadCode(Integer)
(6) -> ([1] pretend BAD(Integer))
#r= 1
(6) 1
Type: BadCode(Integer)
(7) -> ([2] pretend BAD(Integer))
#r= 1
(7) 2
Type: BadCode(Integer)
(8) -> ([1,2] pretend BAD(Integer))
#r= 2
(8) more
Type: BadCode(Integer)
--
This time we get the expected result.
Can you reproduce this? Can anyone see why this happens? What am I missing?
Note: This problem does not seem to occur in OpenAxiom and Axiom.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---