;;; fibonacci.lsp — iterative and recursive Fibonacci
;;; Run: python3 lumbda.py --fast examples/fibonacci.lsp

(define (fib-iter n)
  (let loop ((a 0) (b 1) (i 0))
    (if (= i n) a (loop b (+ a b) (+ i 1)))))

(define (fib-rec n)
  (if (<= n 1) n (+ (fib-rec (- n 1)) (fib-rec (- n 2)))))

(display "fib(30) iterative: ")
(display (fib-iter 30))
(newline)

(display "fib(20) recursive: ")
(display (fib-rec 20))
(newline)

(display "First 15 Fibonacci numbers: ")
(display (map fib-iter (iota 15)))
(newline)
