Slacker News Slacker News logo featuring a lazy sloth with a folded newspaper hat
  • top
  • new
  • show
  • ask
  • jobs
Library
← Back to context

Comment by spider-mario

10 hours ago

`let <var> = <expr> in <expr>` is an expression. Top-level bindings are just `let <var> = <expr>`. That’s pretty much all there is to it.

    let fac =
      let rec fac' acc = function
        | 0 -> acc
        | n -> fac' (n * acc) (n - 1)
      in
      fac' 1

    let seven =
      let four = 4 and three = 3 in
      four + three

https://ideone.com/HpTrI4

0 comments

spider-mario

Reply

No comments yet

Contribute on Hacker News ↗

Slacker News

Product

  • API Reference
  • Hacker News RSS
  • Source on GitHub

Community

  • Support Ukraine
  • Equal Justice Initiative
  • GiveWell Charities