ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  An Introduction to Haskell, Part 1: Why Haskell
Subject:   List comprehension in ruby too...
Date:   2007-05-25 12:24:06
From:   PaulBattley
Response to: List comprehension in ruby too...

You could also do it like this, to make it a bit more explicit:


even = lambda{ |x| x % 2 == 0 }
(1..10).select(&even)


But it's more elegant in Haskell.