forked from orion/obsidian
23 lines
425 B
Markdown
23 lines
425 B
Markdown
|
lambda functions are anonymous functions (as opposed to [[Functions|top-level functions]]) that can be written anywhere:
|
||
|
|
||
|
```haskell
|
||
|
\ <params> -> <body>
|
||
|
```
|
||
|
|
||
|
```haskell
|
||
|
prependHello a = "hello, " <> a
|
||
|
|
||
|
appendName = \a -> a <> "henry!"
|
||
|
|
||
|
str = appendName $ prependHello ""
|
||
|
-- hello, henry!
|
||
|
```
|
||
|
|
||
|
their parameters can destructure their arguments:
|
||
|
```haskell
|
||
|
let
|
||
|
getFoo = \{foo} -> foo
|
||
|
in
|
||
|
getFoo {foo: "hello"}
|
||
|
-- "hello"
|
||
|
```
|