Reputation: 941
How do you unpack array of values into function arguments?
For example, function Iterators.product()
takes variable number of iterators as arguments, i.e.
collect(Iterators.product(1:2, 3:5))
2×3 Array{Tuple{Int64,Int64},2}:
(1, 3) (1, 4) (1, 5)
(2, 3) (2, 4) (2, 5)
Given an array of iterators, such as a=[1:2, 3:5]
, how do you unpack a
without manually accessing it's elements with a[1]
(for example, when length of a
is not known in advance)?
I am hoping there is something like the asterisk operator in Python, (something like Iterators.product(*a)
), but I didn't find anything like that yet.
Upvotes: 6
Views: 1444