Created
September 19, 2016 01:20
-
-
Save mooreniemi/26771e58c3a4961ba1e2a7830b97351c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# pair the sublists together | |
a.zip(b) | |
=> [[[1], [9]], [[2, 3], [8, 7]], [[4, 5, 6], [6, 5, 4]]] | |
# collect up the lengths | |
a.zip(b).collect {|e| e.map(&:length) } | |
=> [[1, 1], [2, 2], [3, 3]] | |
# i want each pair of lengths to be the same, so | |
a.zip(b).collect {|e| e.map(&:length) }.map(&:uniq) | |
=> [[1], [2], [3]] | |
# after i made them uniq, are they singular? | |
a.zip(b).collect {|e| e.map(&:length) }.map(&:uniq).all? {|e| e.size == 1 } | |
=> true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment