Skip to content

Commit 3fa3516

Browse files
committed
Update CL code example: a factorial implementation
1 parent d069a4a commit 3fa3516

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

subsections/index/conceitos-e-fundamentos.org

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,17 @@ Computação Quântica, assim como tem sido usado comercialmente em
6767
softwares como [[http://www.schloerconsulting.com/quantum-computer-q-lisp-programming-language][QLisp Project]].
6868

6969
#+BEGIN_SRC lisp
70+
(defun range (a b)
71+
(loop for x from a to b
72+
collect x))
73+
74+
(defun fact (n)
75+
(reduce #'* (range 1 n)))
7076

7177
(defun hello-world () ;; definição de função
72-
(princ "Hello, Lispers!"))
78+
(format t "Fatorial de 10! é: ~a" (fact 10)))
7379

7480
(hello-world) ;; chamada de função
7581

76-
;; resultado: Hello, Lispers!
82+
;; resultado: Fatorial de 10! é: 3628800
7783
#+END_SRC

0 commit comments

Comments
 (0)