Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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