Filtering Lists
Dec 01
2008
2008
Comments Off
Ruby
arr = (1..10).to_a arr.select{ |e| e % 2 != 0 }
Python
arr = range(1,11) [e for e in arr if e % 2]
Perl
@arr = (1..10); grep($_ % 2, @arr);