I don't know Matlab but I believe what you are after is length as used below.
function demo (x...)
length (x)
end
demo(3, 4, 5)
3
Not sure how long you've been working with Julia but I also was looking for nargin from Matlab when I recently converted to Julia. I figure I would post this for other newbies in my situation. I had a lot of Matlab code like the following
function y = foo(x, z)
if nargin > 1
... do something with x and z ..
else
.... do something with x ...
end
end
Then I realized the multiple dispatch approach of Julia make this much more clean. So in julia I would write
function foo(x)
.... do something with x ...
end
function foo(x, z)
.... do something with x and z ..
end
Cheers,
Ethan
Yes, the variable input arguments is easy for us (matlabers) to adapt for, but I really miss (or didn't find the replacement yet) is the conditional behavior depending on the number of outputs. That is
function y = foo(x, z)
if nargin < 2z = ...default value...end....end
function foo(x, z = ...default value...)...end