the fresh logo: a sliced lemon dripping with juice

Pur

Github

Pur is a simple but powerful functional programming language.

Let's define the natural numbers recursively:


          # 'map' applies 'f' to all the elements in a list
          map(f, []) = []
          map(f, [x, ..xs]) = [f(x), ..map(f, xs)]

          # 'succ' adds 1 to a number
          succ(x) = x + 1

          # 'nats' are the natural numbers
          nats = [0, ..map(succ, nats)]