mirror of
https://github.com/peklaiho/madlisp.git
synced 2024-11-22 13:24:46 +00:00
add comments
This commit is contained in:
parent
aa71b4da36
commit
200d9b3161
@ -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
|
||||
|
@ -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])))
|
||||
|
Loading…
Reference in New Issue
Block a user