Re: #' and lambda
- From: verec <verec@xxxxxxx>
- Date: Sat, 11 Feb 2006 00:20:42 +0000
On 2006-02-10 18:04:02 +0000, Alan Crowe <alan@xxxxxxxxxxxxxxxxxxxxxxx> said:
Thank you all for your explanations.
so the reason this works:
(defun weird-2 (f list)
(reduce f list))
CL-USER 1 > (weird-2 #'+ '(1 2 3))
6
CL-USER 2 > (weird-2 (lambda (a b) (when (and a b) (+ a b))) '(1 2 3))
6
CL-USER 3 > (weird-2 #'(lambda (a b) (when (and a b) (+ a b))) '(1 2 3))
6
is because weird-2 just doesn't care where f comes from,
and because #' special cases (lambda...
But #' doesn't special case anything else, and that's
why:
(defun weird-3 (f list)
(reduce #'f list))
doesn't even compile (well, it does, but issues a warning).
But then
(defun weird-4 (list)
(flet ((f (a b)
(when (and a b)
(+ a b))))
(reduce #'f list)))
does compile, and work:
CL-USER 5 > (weird-4 '(1 2 3))
6
My head still hurts a bit :-(
I'll review all this tomorrow.
Many thanks to all
--
JFB
.
- Follow-Ups:
- Re: #' and lambda
- From: Thomas A. Russ
- Re: #' and lambda
- From: alex . gman
- Re: #' and lambda
- From: Duncan Harvey
- Re: #' and lambda
- References:
- #' and lambda
- From: verec
- Re: #' and lambda
- From: Pascal Costanza
- Re: #' and lambda
- From: verec
- Re: #' and lambda
- From: Duncan Harvey
- Re: #' and lambda
- From: verec
- Re: #' and lambda
- From: Alan Crowe
- #' and lambda
- Prev by Date: sbcl - how to get a REPL for a created thread?
- Next by Date: Re: sbcl - how to get a REPL for a created thread?
- Previous by thread: Re: #' and lambda
- Next by thread: Re: #' and lambda
- Index(es):