def iterate_over(*args, &block)
def _over(memo, rest, block)
if rest.empty?
block.call(memo)
else
(head, *tail) = rest
head.each do |x|
_over(memo + [x], tail, block)
end
end
end
_over([], args, block)
end
iterate_over(array1, array2, array3) do |x, y, z|
puts("#{x} #{y} #{z}")
end
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.