Enumerable#product and #product(initial : Numeric) each will try to multiply the contents of whatever enumerable it is. There is also Array#product(ary : Array(U)) which will produce the set theoretic product of the two arrays.
This is confusing for several reasons:
1: product does totally different things depending on input.
2: There is no way to do a product between actual Sets without converting them to an array.
I'd suggest that at the very least one the second of these issues need to go away. Possibly by moving Array#product into Enumerable (perhaps renamed).
Perhaps it would also be nice to make product (and zip etc) into taking multiple arguments - being able to get flat structures like s1 xs2 x s3 without having to flatten any step would be very convenient in some cases.
What is a product between sets?
https://en.wikipedia.org/wiki/Cartesian_product
so perhaps a Enuerable#cartesian_product instead of Array#product?
Should this even be a Array instance method? Couldn't a Math.cartesian_product(ary, other_ary) serve the same purpose without polluting Array's namespace?
Any updates? @asterite
Most helpful comment
https://en.wikipedia.org/wiki/Cartesian_product
so perhaps a Enuerable#cartesian_product instead of Array#product?