[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: string substitution?

William James

11/8/2015 9:49:00 PM

Joel Wilsson wrote:

> map-values isn't just for strings, it works on other stuff too:
> CL-USER> (map-values 'simple-vector
> (lambda (e)
> (if (oddp e)
> (values 'odd e)
> (values 'even e)))
> #1A(1 2 3 4))
> #(ODD 1 EVEN 2 ODD 3 EVEN 4)

MatzLisp (Ruby):

[1,2,3,4].flat_map{|e| [e.odd? ? :odd : :even, e]}
==>[:odd, 1, :even, 2, :odd, 3, :even, 4]

--
Blacks are an estimated 39 times more likely to commit a violent crime
against a white than vice versa, and 136 times more likely to commit robbery.
www.colorofcrime.com/2005/10/the-color-of-crime-2005/