diff options
Diffstat (limited to 'examples/test.milch')
| -rw-r--r-- | examples/test.milch | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/examples/test.milch b/examples/test.milch index 84193eb..fc41266 100644 --- a/examples/test.milch +++ b/examples/test.milch @@ -1,27 +1,27 @@ -(let! compose (\[f g] +(let compose (\[f g] (\[x] (f (g x))))) ((compose (+ 1) (+ 2)) 3) -(let! id (\[a] a)) +(let id (\[a] a)) -(let! mod (\[n k] +(let mod (\[n k] (- n (* k (/ n k))))) -(let! not (\[b] +(let not (\[b] (match b true false false true))) -(let! is-even (\[n] +(let is-even (\[n] (match (mod n 2) 0 true 1 false))) -(let! is-odd (compose not is-even)) +(let is-odd (compose not is-even)) ;; map :: (a -> b) -> [a] -> [b] -(let! map (\[f lst] +(let map (\[f lst] (match lst [] [] @@ -31,7 +31,7 @@ (map (+ 1) [1 2 3]) ;; foldr :: (a -> b -> b) -> b -> [a] -> b -(let! foldr (\[f accumulator lst] +(let foldr (\[f accumulator lst] (match lst [] accumulator @@ -41,7 +41,7 @@ (foldr + 0 [1 2 3]) ;; filter :: (a -> Bool) -> [a] -> [a] -(let! filter (\[pred lst] +(let filter (\[pred lst] (match lst [] [] otherwise (match (pred (head lst)) @@ -52,20 +52,20 @@ (filter is-even [0 1 2 3 4 5]) -(let! reverse_ (\[v a] - (let! lazy x (head v)) - (let! lazy xs (tail v)) - (let! lazy xa (prepend x a)) +(let reverse_ (\[v a] + (let lazy x (head v)) + (let lazy xs (tail v)) + (let lazy xa (prepend x a)) (match v [] a _ (reverse_ xs xa)))) -(let! reverse (\[v] +(let reverse (\[v] (reverse_ v []))) (reverse [1 2 3]) -(let! flow (\[fs] (foldr compose id (reverse fs)))) -(let! pipe (\[x fs] ((flow fs) x))) +(let flow (\[fs] (foldr compose id (reverse fs)))) +(let pipe (\[x fs] ((flow fs) x))) (pipe 10 [(+ 1) (+ 2)]) |
