I can’t figure out the syntax for doing broadcasting and splatting at the same time
Example:
func(x1, x2) = x1+x2
v = collect(zip(rand(100), rand(100)));
I have function func which takes 2 arguments, and I have vector of tuples. I could splat one element like func(v[1]...). How can I broadcast over the splatted tuples? This doesn’t work: func.(v...). I guess it makes sense, because the splat is being applied to the vector when it should be applied to the elements of the vector, and we really want to broadcast the splatting before broadcasting func. I looked to see if there’s some splat keyword that implements the splatting, so I could do func.(splat.(v)), but it seems such keyword doesn’t exist.
The splatting operator ... is a language feature, while the splat(fun) function is an adaptor exactly for the case that you mentioned. Implementation and docstring:
As @FPGro pointed out, ... is not implemented in terms of Base.splat, but is actually lowered to a call to Core._apply_iterate. You could even write what you want like this: