arliss_obsidian/fp/Language/Expressions/let .. in ...md
Orion Kindel 3ee2a9bbbd
update
2024-09-24 17:52:08 -05:00

34 lines
485 B
Markdown

`let .. in ..` is an expression with some scoped variables, separated by newlines:
```haskell
let
a = 1
b = 2
in
a + b
```
> [!tip]
> there is a second local let-binding syntax, `where`:
> ```haskell
> a + b
> where
> a = 1
> b = 2
> ```
### Examples
Recursive Fibonacci generator, using a helper function `go`
```haskell
fib n =
let
go ns a b =
if Array.length ns == n then
ns
else
go (ns <> [a]) b (a + b)
in
go [] 1 1
```