Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,11 +0,0 @@
|
|||
;; Functional (most elegant and best suited to Lisp dialects):
|
||||
(defun fact (n)
|
||||
"Return the factorial of integer N, which require to be positive or 0."
|
||||
;; Elisp won't do any type checking automatically, so
|
||||
;; good practice would be doing that ourselves:
|
||||
(if (not (and (integerp n) (>= n 0)))
|
||||
(error "Function fact (N): Not a natural number or 0: %S" n))
|
||||
;; But the actual code is very short:
|
||||
(apply '* (number-sequence 1 n)))
|
||||
;; (For N = 0, number-sequence returns the empty list, resp. nil,
|
||||
;; and the * function works with zero arguments, returning 1.)
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
;; Recursive:
|
||||
(defun fact (n)
|
||||
"Return the factorial of integer N, which require to be positive or 0."
|
||||
(if (not (and (integerp n) (>= n 0))) ; see above
|
||||
(error "Function fact (N): Not a natural number or 0: %S" n))
|
||||
(cond ; (or use an (if ...) with an else part)
|
||||
((or (= n 0) (= n 1)) 1)
|
||||
(t (* n (fact (1- n))))))
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
(require 'calc)
|
||||
(calc-eval "fact(30)")
|
||||
=>
|
||||
"265252859812191058636308480000000"
|
||||
Loading…
Add table
Add a link
Reference in a new issue