#7: Progress! No longer breaking!
Bug is now probably in the implementation of CONC rather than in EVAL.
This commit is contained in:
parent
d2ce61e6a7
commit
d563f390c1
4 changed files with 111 additions and 30 deletions
22
resources/sexpr/fact.lsp
Normal file
22
resources/sexpr/fact.lsp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
;; Common Lisp
|
||||
|
||||
(defun range (max &key (min 0) (step 1))
|
||||
(loop for n from min below max by step
|
||||
collect n))
|
||||
|
||||
(mapcar #'(lambda (x) (+ x 1)) (range 10))
|
||||
|
||||
(defun factoriali (n)
|
||||
(reduce #'* (range (+ n 1) :min 1 :step 1)))
|
||||
|
||||
(defun factorialr (n)
|
||||
(cond ((= n 1) 1)
|
||||
(t (* n (factorialr (- n 1))))))
|
||||
|
||||
|
||||
;; Clojure
|
||||
(defn factorial [n]
|
||||
(reduce *' (range 1 (+ n 1))))
|
||||
|
||||
(defn expt [n x]
|
||||
(reduce *' (repeat x n)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue