Re: [比较] 我为何钟情于用 Scala 做为兵刃(三)

楼主: kaluvchris (Juanito)   2011-01-21 05:58:44
如果用Scheme写的话 :)
Scheme:
(length (filter (lambda (x) (> x 5)) (map sqr '(-1 -2 -3 0 1 2 3))))
>> 2
也可以让祂更好读一点
(define gt5?
(lambda (x)
(> x 5)))
(define xs '(-1 -2 -3 0 1 2 3))
(length (filter gt5? (map sqr xs)))

Links booklink

Contact Us: admin [ a t ] ucptt.com