The output of the following function is strange.
Why is dbgPrint executed twice?

%%% (9) -> fooo(2)
   Compiling function bar with type (Integer, Integer) -> List(Integer)

   Compiling function fooo with type Integer -> Integer
[:> , ab, [1, 2]]
[:> , ab, [1, 2]]

   (9)  2
                                  Type: PositiveInteger

NB: If I replace the definition of fooo by

fooo(n: ZZ): ZZ == (_
  n < 2 => error "argument must be > 2";_
  l := bar(1, n);_
  l.2)

the double execution goes away.

Anyway, maybe my assignment of variables inside a list "construct" expression on the left-hand side is not conforming SPAD rules, but I would expect the interpreter either to shout at me or not do the work (function calling) twice. (Or maybe it is only output twice.)

Actually, why is it two times and not three times? It is a list of length 3.

Ralf

--
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 fricas-devel+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/fricas-devel/93de9374-ab52-4a9f-b02e-9a74068c097d%40hemmecke.org.
OF==>OutputForm
display77(x) ==> display((x::OF)::Formatter(Format1D))
yof x ==> x :: Symbol :: OF
dbgPrint(x,y) ==> display77([yof ":> ", yof x, y::OF]$List(OF))

ZZ ==> Integer

digits(100)

bar(a: ZZ, b: ZZ): List ZZ == (_
  dbgPrint("ab", [a,b]$List(ZZ));_
  [a, b, a+b])

fooo(n: ZZ): ZZ == (_
  n < 2 => error "argument must be > 2";_
  [P1n, Q1n, R1n] := bar(1, n);_
  Q1n)

fooo(2)
fooo(2)

Reply via email to