I have a function that takes several arguments. I have another function that returns several values. I’d like the second function to be able to directly feed the first. But my attempt doesn’t work because multiple return values get bundled together in a tuple and my first function doesn’t expect a tuple. (And I don’t want it to, because in most contexts it won’t be eating the direct output of another function.)
Here’s a toy example
function test1(x,y,z)
return x+y+z
end
function test2()
return 1,2,3
end
julia> test1(test2())
ERROR: MethodError: no method matching test1(::Tuple{Int64,Int64,Int64})
Closest candidates are:
test1(::Any, ::Any, ::Any) at REPL[15]:1
Stacktrace:
[1] top-level scope at REPL[20]:1
Anyone have pointers on how to do this in an acceptly Julian way?
Yeah, that has the advantage (or disadvantage, depending on the desired API) that it will throw a method error if you provide a tuple that is too long.
foo(x, y) = x + y
foo((x, y)) = foo(x, y)
bar(x, y) = x + y
bar(x) = bar(x...)