Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CartesianProduct
- include Enumerable
- def initialize(sequence1, sequence2)
- @s1 = sequence1
- @s2 = sequence2
- end
- def each
- @s1.each do |e1|
- @s2.each do |e2|
- yield [e1,e2]
- end
- end
- self # it's good form for an iterator to return self
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement