passing all tests
This commit is contained in:
parent
f86ec13ce9
commit
16b2af9fdb
|
@ -112,16 +112,20 @@
|
|||
|
||||
#+name: pascals-triangle
|
||||
#+begin_src emacs-lisp :var n=5 :exports both
|
||||
(require 'cl)
|
||||
(defalias 'my-map (if (org-version-check "24.1.50" "cl" :predicate)
|
||||
'cl-map
|
||||
'map))
|
||||
(defun pascals-triangle (n)
|
||||
(if (= n 0)
|
||||
(list (list 1))
|
||||
(let* ((prev-triangle (pascals-triangle (- n 1)))
|
||||
(prev-row (car (reverse prev-triangle))))
|
||||
(append prev-triangle
|
||||
(list (map 'list #'+
|
||||
(append prev-row '(0))
|
||||
(append '(0) prev-row)))))))
|
||||
|
||||
(list (my-map 'list #'+
|
||||
(append prev-row '(0))
|
||||
(append '(0) prev-row)))))))
|
||||
|
||||
(pascals-triangle n)
|
||||
#+end_src
|
||||
|
||||
|
|
|
@ -180,7 +180,11 @@
|
|||
|
||||
#+headers: :var letters='(a b c d e f g)
|
||||
#+begin_src emacs-lisp :var numbers='(1 2 3 4 5 6 7)
|
||||
(map 'list #'list numbers letters)
|
||||
(require 'cl)
|
||||
(defalias 'my-map (if (org-version-check \"24.1.50\" \"cl\" :predicate)
|
||||
'cl-map
|
||||
'map))
|
||||
(my-map 'list #'list numbers letters)
|
||||
#+end_src"
|
||||
|
||||
(progn
|
||||
|
|
Loading…
Reference in New Issue