]> gerrit.simantics Code Review - simantics/platform.git/blob - tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/RecursiveContext.scl
Merge commit 'bf75fd9'
[simantics/platform.git] / tests / org.simantics.scl.compiler.tests / src / org / simantics / scl / compiler / tests / scl / RecursiveContext.scl
1 import "JavaBuiltin" as Java\r
2 \r
3 infixl 6  (+), (-)\r
4 \r
5 class Num a where \r
6     (+) :: a -> a -> a\r
7     (-) :: a -> a -> a\r
8     isZero :: a -> Boolean\r
9     one :: a     \r
10     \r
11 instance Num Integer where\r
12     x + y = Java.iadd x y\r
13     x - y = Java.isub x y\r
14     isZero x = Java.icmpeq Java.iconst_0 x\r
15     one = Java.iconst_1\r
16   \r
17 even x = if isZero x then True else odd (x - one)\r
18 odd x = if isZero x then False else even (x - one)   \r
19     \r
20 main = odd (8 :: Integer)\r
21 --\r
22 false\r
23 \r