Created
November 1, 2012 19:02
-
-
Save sheenobu/3995738 to your computer and use it in GitHub Desktop.
Create N lists by unzipping a the results of map.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
even_numbers,odd_numbers,starts_with_one = entire = (1..10).map do |x| | |
[ (x if x % 2 == 0) ,(x if x % 2 != 0), (x if x.to_s[0] == '1') ] | |
end.transpose.map { |x| x.compact } | |
# The entities within the map [ ..., ..., ..N] end up in their respective list | |
# variables. compact is for removing nils from the resulting nested lists. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment