summaryrefslogtreecommitdiff
path: root/fib.kpl
diff options
context:
space:
mode:
Diffstat (limited to 'fib.kpl')
-rw-r--r--fib.kpl10
1 files changed, 10 insertions, 0 deletions
diff --git a/fib.kpl b/fib.kpl
new file mode 100644
index 0000000..a907739
--- /dev/null
+++ b/fib.kpl
@@ -0,0 +1,10 @@
+
+// Fibonacci sequence for all numeric types
+
+fib : Fn[n] $ (
+ ? {
+ n <= 0 { 0 }
+ n < 3 { 2 }
+ { `sync(fib; n - 1) + fib `sync n - 2 }
+ }
+)