aboutsummaryrefslogtreecommitdiff
path: root/test.icl
diff options
context:
space:
mode:
authorCamil Staps2016-03-29 22:42:54 +0200
committerCamil Staps2016-03-29 22:42:54 +0200
commitb23ebc3480b440e1cd26d2bf2ad0fcfe624a13a1 (patch)
tree14536cb27ac3485d478daff1f6f78eb1d52fa511 /test.icl
Initial commit
Diffstat (limited to 'test.icl')
-rw-r--r--test.icl28
1 files changed, 28 insertions, 0 deletions
diff --git a/test.icl b/test.icl
new file mode 100644
index 0000000..95f1276
--- /dev/null
+++ b/test.icl
@@ -0,0 +1,28 @@
+module test
+
+import While
+
+from StdMisc import abort
+from StdOverloaded import class +++(..), class toString(..)
+from StdString import instance +++ {#Char},
+ instance toString Char, instance toString Int
+import _SystemArray
+
+// From http://www.cs.ru.nl/~hubbers/courses/sc/leertaak/04.html
+// The rounded down square root function:
+// { x=n /\ n >= 0 } sqrt { z^2 <= n /\ (z+1)^2 > n }
+sqrt :: Stm
+sqrt = 'z' := 0 :.
+ 'o' := 1 :.
+ 's' := 1 :.
+ While ('s' <= 'x')
+ ( 'z' := 'z' + 1 :.
+ 'o' := 'o' + 2 :.
+ 's' := 's' + 'o' )
+
+Start = toString (tree sqrt st)
+where
+ st :: Var -> Int
+ st 'x' = 16
+
+