> Yes, Spad is irregular here: if '=>' is last in the block, it > effectively is executed in surrouding block.
Sorry, but I don't like that. That is effectively one more rule for a programmer to learn SPAD. And it is unnecessary (IMHO). > We had problem when '=>' was last in the function, this was because > there were no surrouding block. What does that mean? Another rule? I.e. "when => is the last in a block and there is no surrounding block, then ???". Too complicated to remember. I would like the compiler to reject the following function, because there is no return value if x=false. foo(x): Integer == some_computation x => 1$Integer Can you give an example in favour of the current semantic? In fact, I still don't understand the rule including possible exceptions. Also look at the attached programs. The spad and the aldor version output the same. [[1],[2,3,5,7,11,13]] [[4],[3,5,7,11,13]] [[6],[5,7,11,13]] [[10],[7,11,13]] [[12],[11,13]] [[11],[11,13]] [[10],[11,13]] [[9],[11,13]] [[8],[11,13]] [[7],[11,13]] [[6],[11,13]] [[5],[11,13]] [[4],[11,13]] [[3],[11,13]] [[2],[11,13]] [[1],[11,13]] However, according to the rule you gave, the line first l > 0 => n := first rest l is the last of the block following the "then", so it would exit the outer block (which is the block after repeat). Effectively that would have meant that "n := n-1" is not executed, but the while would continue with n=5. Hoever, the "print" statement shows n=4. Sorry, but I cannot predict how => behaves in SPAD. I want the Aldor semantics. ;-) 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 [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 blah.spad blah(1, [2,3,5,7,11,13])
blah.as
Description: application/applix-spreadsheet
)abbrev package BLAH Blah
I ==> SingleInteger
Blah: with
blah: (I, List I) -> I
== add
blah(n: I, l: List I): I ==
while n > 0 repeat
print([[n],l]$List(List I)::OutputForm)
if #l > 2 then
l := rest l
first l > 0 => n := first rest l
n := n - 1
n
