Skip to content

Commit

Permalink
Adding fibonacci example
Browse files Browse the repository at this point in the history
  • Loading branch information
jzbor committed Apr 4, 2024
1 parent 23ef832 commit 41edfe6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions examples/fib.lsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@usestd
@set strategy normal
@set numerals true

iszero := λn.n (λx. FALSE) TRUE;

fibh := \f x. IFTHENELSE
(iszero x)
(\f x . x)
(IFTHENELSE
(iszero (PRED x))
(\f x . f x)
(ADD (f f (PRED x)) (f f (PRED (PRED x)))));
fib := fibh fibh;

@echo ""
@echo "6. Fibonacci number"
listunsorted := !dbg (!cn (fib $6));

0 comments on commit 41edfe6

Please sign in to comment.