Add more higher order functions

main
trivernis 10 months ago
parent 85c9d31950
commit 2db6211c58
Signed by: Trivernis
GPG Key ID: 7E6D18B61C8D2F4B

@ -6,10 +6,17 @@ app "higher-order"
main : Task.Task {} I32 main : Task.Task {} I32
main = main =
fn1 = bind Num.sub 3 fn1 = bind Num.sub 3
fn2 = bindL Num.sub 3 fn2 = bindL Num.mul 3
fn3 = compose fn2 fn1 fn3 = compose fn1 fn2
fn4 = compose fn2 fn1
fn5 = compose (compose fn1 fn2) (compose fn3 fn4)
fn6 : F64 -> Int a
fn6 =
(\n -> n)
|> compose Num.sqrt
|> compose Num.ceiling
results = results =
[fn1 2, fn2 2, fn3 2] [fn1 2, fn2 2, fn3 2, fn4 2, fn5 2, fn6 9]
|> List.map Num.toStr |> List.map Num.toStr
|> List.mapWithIndex \e, idx -> "fn$(Num.toStr idx) -> $(e)" |> List.mapWithIndex \e, idx -> "fn$(Num.toStr idx) -> $(e)"
|> Str.joinWith "\n" |> Str.joinWith "\n"

Loading…
Cancel
Save