| Article: |
An Introduction to Haskell, Part 1: Why Haskell | |
| Subject: | List comprehension in python | |
| Date: | 2007-05-24 05:33:37 | |
| From: | Skink | |
|
To filter the even number in Python I would have used :
|
||
Showing messages 1 through 2 of 2.
-
List comprehension in ruby too...
2007-05-24 08:11:27 pmccann [View]
-
List comprehension in python
2007-05-24 07:52:54 llimllib [View]
Or, to ape the Haskell functional application:
from functools import partial
def even(n): return n%2 == 0
evens = partial(filter, even)
evens(range(1,11))



(1..10).find_all {|i| i % 2 == 0}