Skip to content

Instantly share code, notes, and snippets.

@ender672 ender672/gist:101276
Created Apr 24, 2009

Embed
What would you like to do?
irb(main):001:0> a = [1, 2, 3, 4, 5]
=> [1, 2, 3, 4, 5]
irb(main):002:0> a.each_with_index{|elem, index| a[index..a.size].each{|second_elem| p "#{elem}, #{second_elem}"}}
"1, 1"
"1, 2"
"1, 3"
"1, 4"
"1, 5"
"2, 2"
"2, 3"
"2, 4"
"2, 5"
"3, 3"
"3, 4"
"3, 5"
"4, 4"
"4, 5"
"5, 5"
=> [1, 2, 3, 4, 5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.