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 parameter list? In the positive case, read the next paragraph.

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.

To completely use the power of ERROR, leave your "procedural programming" mentality .

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -