Skip to main content
Relations define named rules.
relation double where
  double(x) = x * 2

query double(5) // 10

Multiple clauses

Clauses are tried top-to-bottom. The first matching clause wins.
relation abs where
  abs(x) = x  when x >= 0
  abs(x) = -x when x < 0

Guards (when)

A clause can have an optional boolean guard:
relation factorial where
  factorial(0) = 1
  factorial(n) = n * factorial(n - 1) when n > 0