Is there outer map function in Julia?

julia

Solution

Using the Iterators package, it might look like this:

using Iterators
for p in product([1,2], [3,4])
    println(p)
end

where you would replace `println` with your algorithm. You can also use `collect` if it's important to get the set of all combinations.

Problem

I am trying to construct all possible combinations of four vectors (parameters in a model) that would give me a big nx4 matrix and I could then run simulation on each set (row) of parameters. In R I would achieve this by using `expand.grid` in Mathematica style, I could use something like outer product with `vcat` and reduce the output using `hcat`. Is there some function analog of `expand.grid` from R or outer map function? Toy example: ``` A = [1 2] B = [3 4] some magic output = [1 3, 1 4, 2 3, 2 4] ```

Original source