[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: Simple recursive list processing question

William James

8/28/2015 4:20:00 PM

Alan Crowe wrote:

> >
> > (reduce #'(lambda (x y) (if y (+ x y) x))
> > some-list
> > :initial-value 0)
> >
> Using a key function has a certain charm
>
> (defun summit (list)
> (reduce (function +) list
> :key (lambda(n)
> (typecase n
> (number n)
> (t 0)))))

Gauche Scheme:

(fold
(lambda (x sum) (+ sum (or x 0)))
0
'(#f 200 8))

===>
208

--
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...)