From my first encounter with Lisp 15 years ago, I would have *sworn*
that it came with the equivalent of Perl's grep {} operator, iow:
(defun select (pred alist)
(mapcan #'(lambda (el)
(and (funcall pred el) (list el)))
alist))
Did I dream? Did it do so little it didn't make it into the standard?
Then what was it called again?
--
Jean-Louis Leroy
http://users.skynet.be/jll
Jean-Louis Leroy <···@skynet.be> writes:
> From my first encounter with Lisp 15 years ago, I would have *sworn*
> that it came with the equivalent of Perl's grep {} operator, iow:
>
> (defun select (pred alist)
> (mapcan #'(lambda (el)
> (and (funcall pred el) (list el)))
> alist))
>
> Did I dream? Did it do so little it didn't make it into the standard?
> Then what was it called again?
this looks an awful lot like REMOVE-IF-NOT.
[i'd have prefered the name KEEP-IF (and NKEEP-IF for non-consing
variant) but who am i?]
--
J o h a n K u l l s t a m
[········@ne.mediaone.net]
sysengr
Johan Kullstam <········@ne.mediaone.net> wrote:
>Jean-Louis Leroy <···@skynet.be> writes:
>
>> From my first encounter with Lisp 15 years ago, I would have *sworn*
>> that it came with the equivalent of Perl's grep {} operator, iow:
>>
>> (defun select (pred alist)
>> (mapcan #'(lambda (el)
>> (and (funcall pred el) (list el)))
>> alist))
>>
>> Did I dream? Did it do so little it didn't make it into the standard?
>> Then what was it called again?
>
>this looks an awful lot like REMOVE-IF-NOT.
>
Would say like filter :
(defun filter (fn list)
(loop for x in list
when (funcall fn x)
collect x))
--
Francis Leboutte
··@algo.be www.algo.be +32-(0)4.388.39.19
Johan Kullstam <········@ne.mediaone.net> writes:
> > (defun select (pred alist)
> > (mapcan #'(lambda (el)
> > (and (funcall pred el) (list el)))
> > alist))
> >
> > Did I dream? Did it do so little it didn't make it into the standard?
> > Then what was it called again?
>
> this looks an awful lot like REMOVE-IF-NOT.
Yesss! Funny, I knew about remove-if-not but I was confused by the
double negation it seems <g>
--
Jean-Louis Leroy
http://users.skynet.be/jll
Jean-Louis Leroy <···@skynet.be> writes:
> From my first encounter with Lisp 15 years ago, I would have *sworn*
> that it came with the equivalent of Perl's grep {} operator, iow:
REMOVE-IF-NOT ? Or DELETE-IF-NOT, if you can live with possible
destructiveness.
-dan
--
http://ww.telent.net/cliki/ - CLiki: CL/Unix free software link farm