From 25681f822f4a965ca38efa47eed9927b0edc75c7 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Wed, 30 Mar 2016 10:54:45 +0200 Subject: Overloaded state, more boolean ops, unaliased Var --- README.md | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 0619e88..a69c119 100644 --- a/README.md +++ b/README.md @@ -17,23 +17,26 @@ For example, the [following program][sqrt] is a rounded down square root function (if `x=n` at the start and `n` is a natural number, then `z` is the square root of `n`, rounded down, after execution): + import While + from WhileVars import o, s, x, z // o :== Var 'o'; etc. + 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 ) ### Evaluation -We can now execute this code on a `State`, which maps `Var` (`Char`) to `Int`: +We can now execute this code on a `State`, which maps `Var` to `Int`: Start :: Int - Start = eval NS sqrt st 'z' + Start = eval NS sqrt st z where - st :: Var -> Int - st 'x' = 36 + st :: Char -> Int // Or: st :: Var -> Int // st :: CharState + st 'x' = 9 // st (Var 'x') = 9 // st = \'x' -> 9 `eval NS sqrt st` is a `State` itself (the state that results from execution of `sqrt` in `st`), so we apply that to `z` to get the result. Other than the @@ -135,8 +138,6 @@ qualified imports where needed. ## Todo - Gast testing - - More boolean operators for testing integers besides `==` and `<=` - - Can boolean operators be made functions rather than type constructors? - Prettyprint for `DerivTree` - Parser - Add the state to the `toString` of `DerivTree` and `DerivSeq` -- cgit v1.2.3