For my first question here I would like to ask you how you'd do the following in Ruby.
I have a hash with the following aspect
variables["foo"] = [1,2,3]
variables["bar"] = [4,5,6,7]
variables[...] = ...
Update: this hash will have an arbitrary number of key => values pairs.
So it represents parameters and their possible values. I would like to "generate" now an Array containing hashes whose key=>value pairs represent each possible combination of the variables. In the case of the example above, I would have an array of 12 (=3x4) hashes like that
[ hash1, hash2, ..., hash16]
where hash*i* would be
hash1["foo"] = 1
hash1["bar"] = 4
hash2["foo"] = 1
hash2["bar"] = 5
hash3["foo"] = 1
hash3["bar"] = 6
hash4["foo"] = 1
hash4["bar"] = 7
hash5["foo"] = 2
hash5["bar"] = 4
hash6["foo"] = 3
hash6["bar"] = 4
...
hash16["foo"] = 3
hash16["bar"] = 7
I have a few ideas but all of them are quite complicated nested loops ...
Thanks a lot !