From 27140802f75d4e0e2f6ab62ad3179741a72cc4f4 Mon Sep 17 00:00:00 2001 From: Scott Richmond Date: Tue, 4 Jul 2023 12:42:56 -0400 Subject: [PATCH] Sandbox! --- sandbox.ld | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/sandbox.ld b/sandbox.ld index 2b2c057..f2bcfd1 100644 --- a/sandbox.ld +++ b/sandbox.ld @@ -1,32 +1,4 @@ -fn unwrap { - ((:some, value)) -> value - ((:ok, value)) -> value -} -fn default (default_value) -> fn (maybe) -> match maybe with { - (:ok, value) -> value - (:err, _) -> default_value - nil -> default_value - value -> value -} - -fn some (value) -> (:some, value) - -fn ok (value) -> (:ok, value) - -let foo = unwrap ((:ok, 42)) - -print (:foo, foo) - -let bar = unwrap ((:some, 23)) - -print (:bar, bar) - -let baz = do 69 > default (12) > print (:baz, _) - -let quux = do nil > default (12) > print (:quux, _) - -& unwrap ((:err, "message")) fn map { (f) -> fn mapper (xs) -> map (f, xs) @@ -74,6 +46,8 @@ fn filter { let greater_than_two = gt (_, 2) +fn square (x) -> mult (x, x) + let xs = [1, 2, 3] -filter (greater_than_two ,xs) +map (square, xs)