Re: legitimate closure?
- From: Rainer Joswig <joswig@xxxxxxx>
- Date: Sat, 30 Aug 2008 23:00:28 +0200
In article
<82bfc8fb-154e-47d2-b3ab-c50d6a2c904a@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Mirko.Vukovic@xxxxxxxxx wrote:
This closure works on clisp on cygwin+windows:
cl-user> (let ((list (list 1 2 3 4 5))
(item 4))
(delete item list :test #'(lambda (unused b) (= item b))))
(1 2 3 5)
I used closure for lambda to get "item" from delete's first argument
Not sure what you are saying, but the ITEM in the LAMBDA form
refers to the ITEM introduced by the LET. That's fine.
The ITEM as a argument to DELETE is also referring to
the ITEM introduced by the LET. That's fine, too.
UNUSED has in every call of the LAMBDA function
the value of ITEM. So ITEM and UNUSED have the same value.
The straightforward version is
cl-user> (let ((list (list 1 2 3 4 5))
(item 4))
(delete item list :test #'(lambda (a b) (= a b))))
I'm not sure why would this ever be useful, but I was surprised that
lambda captured it.
I thought that the most straightforward way would call DELETE like
this:
(delete item list)
or
(delete item list :test #'=) if you want to call the
= function.
:test (lambda (a b) (= a b)) is the more complicated version of
:test #'=
Mirko
--
http://lispm.dyndns.org/
.
- References:
- legitimate closure?
- From: Mirko . Vukovic
- legitimate closure?
- Prev by Date: legitimate closure?
- Next by Date: Re: legitimate closure?
- Previous by thread: legitimate closure?
- Next by thread: Re: legitimate closure?
- Index(es):
Relevant Pages
|