Re: legitimate closure?
- From: "Alex Mizrahi" <udodenko@xxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 31 Aug 2008 00:28:28 +0300
MV> This closure works on clisp on cygwin+windows:
MV> cl-user> (let ((list (list 1 2 3 4 5))
MV> (item 4))
MV> (delete item list :test #'(lambda (unused b) (= item b))))
MV> (1 2 3 5)
MV> I used closure for lambda to get "item" from delete's first argument
your broken comparison function has no relation whatsoever to delete's
first argument. try this:
(let ((list (list 1 2 3 4 5))
(item 4))
(delete 777 list :test #'(lambda (unused b) (= item b))))
(1 2 3 5)
if you do not use "item" parameter, use delete-if instead of delete:
(let ((list (list 1 2 3 4 5))
(item 4))
(delete-if (lambda (unused b) (= item b)) list))
MV> I'm not sure why would this ever be useful, but I was surprised that
MV> lambda captured it.
the only thing lambda capture are lexical variables, introduced by LET,
function parameters and stuff like this.
.
- References:
- legitimate closure?
- From: Mirko . Vukovic
- legitimate closure?
- Prev by Date: Re: legitimate closure?
- Next by Date: Re: Fundamental Problems of Lisp
- Previous by thread: Re: legitimate closure?
- Index(es):
Relevant Pages
|