Why does foo(true, true) not output the same as bar(true, true)?
Obviously, => means something

Ralf

echo ")r foo.input" | fricas -nosman

foo(true, true)

   (2)  "mooTT"

foo(true, false)

   (3)  "mooTT"          <--- WRONG

-- That should be "mooinit".

foo(true, true)

   (4)  "mooinit"

foo(false, false)

   (5)  "mooinit"

=====================================

(6) -> )co foo.spad

(6) -> bar(true, true)

   (6)  "TT"            <----WRONG

-- The "=>" should leave the "then" block, but not return
-- from the function.
-- Uncomment the line
--    str := "TF"
-- and the result will correctly be "mooTT" here and "mooTF" for (7).

(7) -> bar(true, false)

   (7)  "mooinit"

(8) -> bar(false, true)

   (8)  "mooinit"

(9) -> bar(false, false)

   (9)  "mooinit"


=====================================

aldor -grun -laldor foo.as
mooTT
mooinit
mooinit
mooinit

-- 
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.
)co foo.spad
bar(true, true)
bar(true, false)
bar(false, true)
bar(false, false)
foo(x: Boolean, y: Boolean): String ==
  str: String := "init"
  if x then
--    str := "TF"
    y => (str := "TT")
  str := concat("moo", str)
  str

foo(true, true)
foo(true, false)
foo(false, true)
foo(false, false)
)abbrev package FOO Foo
Foo: with
    bar: (Boolean, Boolean)->String
  == add
    bar(x: Boolean, y: Boolean): String ==
      str: String := "init"
      if x then
--        str := "TF"
        y => (str := "TT")
      str := concat("moo", str)
      str

Attachment: foo.as
Description: application/applix-spreadsheet

Reply via email to