Try prod = prod.product(ranges) without loop.


2011/12/8 S˝├astien M. <stkfdt / gmail.com>:
> Hi,
>
> I'm trying to remove a array layer implied by multiple Array#product
>
> Here is the code
> ----------------
> def calculate ranges
> rod = ranges.shift
> anges.each { |r| prod = prod.product(r) }
> uts prod.to_s
> end
> ---------------------------------------------
> Here is what i do get
> ----------------------
> [
> [["a", "b"], ["e", "f"]], ["i", "j"]],
> [["a", "b"], ["e", "f"]], ["k", "l"]],
> ..
> ]
> -------------------------------------------
> And there is what i wish
> ------------------------
> [
> ["a", "b"], ["e", "f"], ["i", "j"]],
> ["a", "b"], ["e", "f"], ["k", "l"]],
> ..
> ]
>
> Probably a silly question, but it's driving me mad.
> I tried flatten, prod = prod[0], using Array#permutation, ...
> Can't find my way out..???
>
> Thanks
>
> --
> Posted via http://www.ruby-forum.com/.
>