Google Groups

Unexpected behaviour due to order of definitions


Liam Goodacre Jan 28, 2012 6:51 PM
Posted in group: lastcalc
Using the following declarations:

range(X)(Y) = if X<Y then [X...range(X+1)(Y)] else []
range(X) = range(0)(X)

step([]) = []
step([H...T]) = if T!=[] then [H,step(T)] else [H]

Depending on which is declared first, here are my findings:

Range defined before Step (expected behaviour):
step(range(5))
-> [0, [1, [2, [3, [4]]]]]

Range defined after Step (unexpected behaviour):
step(range(5))
-> step ([0...[1...[2...[3...[4]]]]])