Skip to content

Instantly share code, notes, and snippets.

@rgs1
Created March 5, 2014 19:23
Show Gist options
  • Save rgs1/9374585 to your computer and use it in GitHub Desktop.
Save rgs1/9374585 to your computer and use it in GitHub Desktop.
def gen(v)
if v.length == 1
yield v
end
v.each { |i|
gen(v.slice(1, v.length)) { |v1|
yield [i] + v1
}
}
end
gen(ARGV) { |sentence|
puts sentence.join(" ")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment