readable/factorial.lisp
David A. Wheeler e13f2ac9e2 factorial.*lisp: Improve Common Lisp short demo files.
- In particular, rename "fact" to "factorial" so the demo
    doesn't interfere with the built-in factorial function.
2014-11-18 17:38:07 -05:00

25 lines
534 B
Common Lisp

; This is a trivial demo of sweet-expressions in Common Lisp.
; This version uses ASDF.
; Run as:
; clisp -q -q factorial.lisp
; To use the NOT installed version of the readable library, prepend with:
; CL_SOURCE_REGISTRY="$PWD"
; where $PWD is wherever the files sweet.lisp (etc.) are installed.
(require "asdf")
(asdf:load-system :readable)
(readable:enable-sweet)
(setq *print-escape* nil) ; Optional
defun factorial (x)
if {x < 1}
1
{x * factorial{x - 1}}
princ factorial(5)
(readable:disable-readable)