Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdearman committed Jun 9, 2024
1 parent 2fb4a1e commit 599e1b2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions examples/mvp.scm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@
(if (= i 0)
a
(loop b (+ a b) (- i 1)))))

;; def fib_iter n =
;; let loop a b i =
;; if i = 0 then a
;; else loop b (a + b) (i - 1)
;; in loop 0 1 n

(def (fib-iter n)
(letf (loop a b i)
(if (= i 0)
a
(loop b (+ a b) (- i 1)))
(loop 0 1 n)))

;; this could also be done with a `match` expression
(def (fib n)
Expand Down

0 comments on commit 599e1b2

Please sign in to comment.