How can one have a function that uses a dynamic amount of each
statements? Below is the code for level 3. Is there a way to define this
easily using recursion? I want to avoid having a separate function for
each level.

def calc nums, level
  tmp = []
  nums.each{ |n| tmp.push n
    nums.each{ |n2| tmp.push n+n2
      nums.each{ |n3| tmp.push n+n2+n3
      }}}
  tmp
end

puts calc(["0", "1"], 3)
-- 
Posted via http://www.ruby-forum.com/.