]> gerrit.simantics Code Review - simantics/platform.git/blob - tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/Primes.scl
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / tests / org.simantics.scl.compiler.tests / src / org / simantics / scl / compiler / tests / scl / Primes.scl
1 import "JavaBuiltin" as Java
2
3 infixl 7  (%)
4 infixl 6  (+)
5 infix  4  (<)
6
7 (+) = Java.iadd
8 (%) = Java.irem
9 (<) = Java.icmplt
10
11 isPrime p = isPrimeAux (2 :: Integer) p
12   where
13     isPrimeAux d p = if d == p then True
14                      else if p % d == 0 then False
15                      else isPrimeAux (d+1) p
16                    
17 nextPrime p = if isPrime p 
18               then p
19               else nextPrime (p+(1 :: Integer))                   
20                      
21 main = nextPrime 32
22 --
23 37