]> gerrit.simantics Code Review - simantics/platform.git/blob - tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/Collaz.scl
Automatic execution of SCL tests in Maven
[simantics/platform.git] / tests / org.simantics.scl.compiler.tests / src / org / simantics / scl / compiler / tests / scl / Collaz.scl
1 import "Prelude"\r
2 \r
3 f x = if x `mod` 2 == 0\r
4       then x `div` 2\r
5       else 3*x + 1\r
6 fd x = unfoldr (\x -> do\r
7                    r = f x \r
8                    if x == 1\r
9                    then Nothing\r
10                    else Just (x,r)\r
11                 ) x\r
12 \r
13 //main :: [Integer]                \r
14 main = fd 7\r
15 --\r
16 [7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2]