Variable length of function argument list in Erlang -
Is it possible to define tasks with the variable length logic?
I know that I can only write:
function () - & gt; Ceremony ([]) Function (x) when not is_list (x) - & gt; Ceremony ([X]); Function (x) - & gt; Do_something_with_arguments (x).
But I want to avoid this technique.
The only way to do this is to give all the arguments in one list:
< P> function (ListOfParameters)
And then you said ListOfParameters
. In this way, you may be able to accept any "Parameter" declaration of your function, just add more conditions to declare ... but I'm not sure what you were hoping for. Are you thinking on the lines of a C code
You must remember that the Eralong is based on pattern matching. The arguments given in the function "declaration" provide a function as a matching pattern if applicable.
Comments
Post a Comment