mirror of
https://github.com/vinc/moros.git
synced 2024-06-17 14:37:04 +00:00
ec57ff1540
* Adopt a syntax closer to scheme * Add parse and eval * Replace Exp::Func with Exp::Primitive * Refactor built in autocompletion * Replace null by nil * Fix test * Update doc * Bump version
15 lines
301 B
Plaintext
15 lines
301 B
Plaintext
(load "/lib/lisp/core.lsp")
|
|
|
|
(define (factorial-helper n acc)
|
|
(cond
|
|
((< n 2) acc)
|
|
(true (factorial-helper (- n 1) (* acc n)))))
|
|
|
|
(define (factorial n)
|
|
(factorial-helper n 1))
|
|
|
|
(println
|
|
(cond
|
|
((nil? args) "Usage: factorial <num>")
|
|
(true (factorial (string->number (car args))))))
|