orca/ext/wasm3/test/wasi/mal/test-fib.mal

9 lines
235 B
Plaintext
Raw Permalink Normal View History

2023-04-12 14:21:03 +00:00
;; Compute a Fibonacci number with two recursions.
(def! fib
(fn* [n] ; non-negative number
(if (<= n 1)
n
(+ (fib (- n 1)) (fib (- n 2))))))
(println (fib (read-string (first *ARGV*))))