]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/Compose.scl
Automatic execution of SCL tests in Maven
[simantics/platform.git] / tests / org.simantics.scl.compiler.tests / src / org / simantics / scl / compiler / tests / scl / Compose.scl
diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/Compose.scl b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/Compose.scl
new file mode 100644 (file)
index 0000000..fad8b9b
--- /dev/null
@@ -0,0 +1,20 @@
+import "JavaBuiltin" as Java\r
+\r
+(+) = Java.iadd\r
+(-) = Java.isub\r
+(*) = Java.imul\r
+\r
+data List a = Nil | Cons a (List a) \r
+\r
+compose :: List (a -> a) -> a -> a\r
+compose Nil        x = x\r
+compose (Cons h t) x = compose t (h x)\r
+\r
+succ x = x + 1\r
+prec x = x - 1\r
+double x = x * 2\r
+\r
+f = compose (Cons succ (Cons double (Cons prec Nil)))\r
+main = f 13\r
+--\r
+27
\ No newline at end of file