]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/ClosureRecursion.scl
(refs #7042) Added a new compiler optimization (eta-reduce)
[simantics/platform.git] / tests / org.simantics.scl.compiler.tests / src / org / simantics / scl / compiler / tests / scl / ClosureRecursion.scl
diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/ClosureRecursion.scl b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/ClosureRecursion.scl
new file mode 100644 (file)
index 0000000..4b31b1d
--- /dev/null
@@ -0,0 +1,21 @@
+import "Prelude"
+
+countDown :: Ref Integer -> <Proc> Boolean
+countDown r = if currentValue <= 0
+              then False
+              else do 
+                  r := currentValue - 1
+                  True
+  where
+    currentValue = getRef r 
+
+strangeLoop :: (<Proc> Boolean) -> <Proc> ()
+strangeLoop cond = if cond
+                   then strangeLoop cond
+                   else ()
+
+main = do
+    r = ref 100000 :: Ref Integer
+    strangeLoop (countDown r)
+--
+()
\ No newline at end of file