Standard Library
Currently, due to the language being in its preliminary phases, there is no standard library. However, if you would like to help write one, I would definitely appreciate it. Email me at brendon.bown@gmail.com, and I'll direct you in learning more. Or you can help develop Tego itself so that it can reach a stable phase.
Examples
Hello world!
main = "Hello world!"
Add one
main = addOne 1
addOne i = i + 1
Fibbonacci Sequence
main = fib 5
fib = fib' 0 1
fib' a b n =
match n to
| 0 -> b
| n -> fib' b (a + b) (n - 1)
Fibbonacci Sequence (Free Monoids)
main = fibList 45
fibList = fibList' 0 1
fibList' a b n =
match n to
| 0 -> b
| n -> b, fibList' b (a + b) (n - 1)
Primes
main = primes 50
primes = primes' () 2
primes' ps curr n =
if n <= 0 then
ps
else if not (isDivisible curr ps) then
primes' (ps, curr) (curr + 1) (n - 1)
else
primes' ps (curr + 1) n
-- Test whether 'n' is divisible by any number in 'primes'
isDivisible n primes =
match primes to
| () -> false
| p, px -> if n % p == 0 ? true else isDivisible n px