The inevitable hello world
:
def app|main() outln("hello world")
Compute fibonacci numbers:
def fib(n) if (n < 2) 1 else fib(n - 1) + fib(n - 2) def app|main() let n = 28 outln("Fib(%d): %d" % #[n, fib(n)])
99 bottles of beer
:
module beer99 import "io/io.h" def bottles(n : Int) for (i in n .. 0 by -1) { let number-str = select (i) { | 0 -> "No more bottles" | 1 -> "One bottle" | else "%d bottles" % i } outln("%s of beer on the wall" % number-str) outln("%s of beer" % number-str) outln("Take one down, pass it around") outln("%s of beer on the wall" % number-str) outln() } def app|main() bottles(99)