aboutsummaryrefslogtreecommitdiff
path: root/test.icl
diff options
context:
space:
mode:
authorCamil Staps2016-03-30 10:54:45 +0200
committerCamil Staps2016-03-30 11:25:31 +0200
commit25681f822f4a965ca38efa47eed9927b0edc75c7 (patch)
tree3d7b1bd603f83f5a5f4faff85939dd397beb67c2 /test.icl
parentReadme: features, headings (diff)
Overloaded state, more boolean ops, unaliased Var
Diffstat (limited to 'test.icl')
-rw-r--r--test.icl23
1 files changed, 13 insertions, 10 deletions
diff --git a/test.icl b/test.icl
index 54668f2..fe689fc 100644
--- a/test.icl
+++ b/test.icl
@@ -1,6 +1,7 @@
module test
import While
+from WhileVars import o, s, x, z
from StdMisc import abort
from StdOverloaded import class +++(..), class toString(..)
@@ -12,18 +13,20 @@ import _SystemArray
// 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' )
+sqrt = z := 0 :.
+ o := 1 :.
+ s := 1 :.
+ While (s <= x)
+ ( z := z + 1 :.
+ o := o + 2 :.
+ s := s + o )
-//Start = toString (seq sqrt st)
-Start = toString (tree sqrt st)
+Start :: Int // Value of z after execution of sqrt in st
+Start = eval NS sqrt st z
+//Start = toString (seq sqrt st) // Derivation sequence of sqrt in st
+//Start = toString (tree sqrt st) // Derivation tree of sqrt in st
where
- st :: Var -> Int
+ st :: Char -> Int
st 'x' = 9