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

485 B

let .. in .. is an expression with some scoped variables, separated by newlines:

let
  a = 1
  b = 2
in
  a + b

Tip

there is a second local let-binding syntax, where:

a + b
  where
    a = 1
    b = 2

Examples

Recursive Fibonacci generator, using a helper function go

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