[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: List comprehensions in Lisp

William James

11/15/2015 8:33:00 PM

Pascal Costanza wrote:

> > Python has a feature called list comprehensions.
> > eg : a = [1 2 3 4]
> > b = [2*x for x in a if x<3]
> > results in b = [2 4]
> >
> > Now similar filtering can be achieved by mapcan :see an example in
> > Cltl2.
>
> ...and the LOOP macro, of course:
>
> (loop for x in a
> when (< x 3)
> collect (* 2 x))

MatzLisp (Ruby):

(3..24).grep->(n){n.odd?}{|n| 2*n}
==>[6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46]

--
In Australia, Norway, and Sweden there is a distinct race-based crime in which
Islamic men are raping Western women for ethnic reasons. We know this because
the rapists have openly declared their sectarian motivations. ---
amren.com/news/2005/12/the_epidemic_of_ethnic_rape/