From e06bf5c88f10c14286ea9fd91f4bdba00cda6da9 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 16 Aug 2022 23:17:41 +0200 Subject: Enhanced examples --- README.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6f6eb2f..fc4e39a 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,8 @@ understanding the logic of lambda calculus: # we can use the function in all functions below its definition get-one2 get-one + # tests are similar to assertions in other languages + # in this example they're used to show the reduced expressions :test (get-one2) (+1) # indenting acts similarly to Haskell's where statement @@ -190,6 +192,7 @@ Some other great functions: :import std/Number . :import std/Option . :import std/Pair . + :import std/List . # pairs with some values love pair me you @@ -199,10 +202,6 @@ Some other great functions: :test (fst love) ([[[1]]]) :test (snd love) ([[[2]]]) - # options - :test (map inc (some (+1))) (some (+2)) - :test (apply (some (+1)) [some (inc 0)]) (some (+2)) - # numerical operations five --(((+8) + (-4)) - (-2)) @@ -212,6 +211,15 @@ Some other great functions: :test ((uncurry mul (pair (+3) (+2))) =? (+6)) (true) + # lazy evaluation using infinite lists and indexing + pow2 [(iterate (mul (+2)) (+1)) !! 0] + + :test (pow2 (+5)) (+32) + + # options + :test (map inc (some (+1))) (some (+2)) + :test (apply (some (+1)) [some (inc 0)]) (some (+2)) + # boolean main not ((false && true) || true) -- cgit v1.2.3