Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 23 |
Nodes: | 6 (0 / 6) |
Uptime: | 52:43:46 |
Calls: | 583 |
Files: | 1,139 |
D/L today: |
179 files (27,921K bytes) |
Messages: | 111,617 |
(defun map-> (fn start test-fn succ-fn)
(do ((i start (funcall succ-fn i))
(result nil))
((funcall test-fn i) (nreverse result))
(push (funcall fn i) result)))
(defun map-> (fn start test-fn succ-fn)
(do ((i start (funcall succ-fn i))
Why "(funcall succ-fn i))"? Why not simply "(succ-fn i))"?
What a clunky, bloated, and hideous language!
Daniel Weinreb, 24 Feb 2003:
Having separate "value cells" and "function cells" (to use
the "street language" way of saying it) was one of the most
unfortunate issues. We did not want to break pre-existing
programs that had a global variable named "foo" and a global
function named "foo" that were distinct. We at Symbolics
were forced to insist on this, in the face of everyone's
knowing that it was not what we would have done absent
compatibility constraints. It's hard for me to remember all
the specific things like this, but if we had had fewer
compatibility issues, I think it would have come out looking
more like Scheme in general.
Daniel Weinreb, 28 Feb 2003:
Lisp2 means that all kinds of language primitives have to
exist in two versions, or be parameterizable as to whether
they are talking about the value cell or function cell. It
makes the language bigger, and that's bad in and of itself.
Just as a dung beetle treasures excrement, disciples of CL
treasure all of the deformities of their repulsive language.
(result nil))
((funcall test-fn i) (nreverse result))
Why "(funcall test-fn i)"? Why not simply "(test-fn i)"?
(push (funcall fn i) result)))
Why "(funcall fn i)"? Why not simply "(fn i)"?
Testing:
(map-> 'exp 1 (lambda(n)(> n 4)) '1+)
===>
(2.7182817 7.389056 20.085537 54.59815)
Let's show the CL disciple the right way to use "do":
(define (map-> fn start test-fn succ-fn)
(do ((i start (succ-fn i))
(result '() (cons (fn i) result)))
((test-fn i) (reverse result))))
(map-> exp 1 (lambda(n)(> n 4)) (pa$ + 1))
===>
(2.718281828459045 7.38905609893065 20.085536923187668 54.598150033144236)