Fibs and Facts
Jump to navigation
Jump to search
Fibonacci and Factorial are two of the basic examples for functional programming languages. Here we show their implementation in Wu.
Fibonacci
fib n = (> 2 n) 1 (+ 1 (+ (fib (- n 1) (- n 2)))); linfib x y n = (== 0 n) y (linfib y (+ x y) (- n 1));
Factorial
fact n = (> 2 n) 1 (* n (fact (- n 1))); fact n = foldr + 0 (range 1 n);