Sandbox!
This commit is contained in:
parent
d87a0eddc5
commit
27140802f7
32
sandbox.ld
32
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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user