• Re: Road to Clojure Survey 2.0

    From B. Pym@Nobody447095@here-nor-there.org to comp.lang.lisp on Thu Aug 14 05:11:08 2025
    From Newsgroup: comp.lang.lisp

    than version you've wrote in CL. i would write it like this:

    (defun factorial (n)
    (loop with p = 1
    for i from 1 to n
    do (setf p (* p i))
    finally (return p)))

    IMHO that's cleaner. or if i absolutely must use recursion:

    It's shorter when one uses a Lispy language instead of CL.

    (define (factorial n)
    (do ((i n (- i 1))
    (r 1 (* r i)))
    ((< i 1) r)))

    (factorial 5)
    ===>
    120

    (factorial -2)
    ===>
    1
    --
    The good news is, it's not Lisp that sucks, but Common Lisp. --- Paul Graham --- Synchronet 3.21a-Linux NewsLink 1.2