Specifically I am seeking something like the following in python:
def foo(x,y):
return x+y
a = [1,2]
foo(*a)
Specifically I am seeking something like the following in python:
def foo(x,y):
return x+y
a = [1,2]
foo(*a)
julia> function foo(x,y)
x+y
end
foo (generic function with 1 method)
julia> a=[1,2]
2-element Array{Int64,1}:
1
2
julia> foo(a...)
3
It’s called splatting:
https://docs.julialang.org/en/v1/manual/faq/#The-two-uses-of-the-…-operator:-slurping-and-splatting
Note that you want to be careful with splatting large arrays, because contrary to Python, Julia usually specializes on positional and keyword arguments, so if the array you are splatting is large, compile time latency can get out of hand quite quickly. Splatting typically works best for relatively small tuples, because tuples are always statically sized and always contain all the type information the Julia compiler needs to generate efficient code. In these cases, splatting is often free at runtime, which can be really useful.