This commit is contained in:
Scott Richmond 2023-07-04 12:42:56 -04:00
parent d87a0eddc5
commit 27140802f7

View File

@ -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)