add comments

This commit is contained in:
Pekka Laiho 2020-06-08 09:55:29 +07:00
parent aa71b4da36
commit 200d9b3161
2 changed files with 2 additions and 2 deletions

View File

@ -1,6 +1,6 @@
;; Functions to calculate factorial
;; Recursive version
;; Recursive version, not tail call optimized
(def recFact (fn (n) (if (< n 2) 1 (* n (recFact (- n 1))))))
;; Apply version

View File

@ -6,6 +6,6 @@
;; Return the sum of the last 2 numbers in a sequence
(def sumOfLast (fn (l) (+ (last l) (get l (- (len l) 2)))))
;; Faster version, return vector of n numbers
;; Faster version, return vector of n numbers, tail call optimized
(def fibListRec (fn (n l) (if (< (len l) n) (fibListRec n (push l (sumOfLast l))) l)))
(def fibList (fn (n) (fibListRec n [0 1])))