[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: shootout: implementing an interpreter

William James

12/27/2015 5:18:00 PM

> So the product of the sums of the elements of two lists could be
> written using iterate as:
>
> (iter (x in xs)
> (y in ys)
> (if (= (+ x y) 0) (leave 0))
> (multiply (+ x y) into z)
> (finally z))

MatzLisp (Ruby):

xs = [0,1,2]
ys = [4,5,6]

xs.zip(ys).reduce(1){|z,(x,y)| t=x+y; break 0 if t.zero?; z*t}
===>
192

--
Amazon bans book. After nearly a month on the site, all traces of the book and
its 80 reviews have been removed.
http://jamesfetzer.blogspot.com/2015/11/debunking-sandy-hook-debunk...
https://www.youtube.com/watch?v=E...