[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: I still don't get MAPCAN

William James

11/4/2015 11:41:00 PM

Ken Tilton wrote:

> > MAPCAN is terribly useful when you want to collect only some things:
> >
> > (defun find-interesting (huge-list)
> > (mapcan #'(lambda (e) (if (interestingp e) (list e) nil)) huge-list))
>
> ick.
>
> (loop for e in huge-list when (interestingp e) collect e)

Gauche Scheme:

(filter interesting? huge-list)

Only a dung-beetle (a worshipper of CL) would prefer Kenny's version.

MatzLisp (Ruby):

huge_array.select(&:interesting?)

or

huge_array.select{|x| interesting?(x)}

--
You have politicians saying that ... as many Africans as want to come into
Sweden should be able to come.... They've already said that everybody from
Syria can come to Sweden.... [T]hey are actually thinking of commandeering
people's vacation homes because they need more housing for immigrants.
--- Dr. Kevin MacDonald (http://lnrlive.com/tpc/tpc201...)