Variadic function: Difference between revisions
Content added Content deleted
(add BQN) |
|||
Line 638: | Line 638: | ||
little |
little |
||
lamb</pre> |
lamb</pre> |
||
=={{header|BQN}}== |
|||
All BQN functions can be variadic since they allow taking arbitrary length lists as arguments. A function can reject variadicity by defining a header to restrict the arguments to a specific length. |
|||
<lang bqn>Fun1 ← •Show¨ |
|||
Fun2 ← {•Show¨𝕩} |
|||
Fun3 ← { 1=≠𝕩 ? •Show 𝕩; "too many arguments " ! 𝕩}</lang> |
|||
Both Fun1 and Fun2 display all the values(arguments) of the lists given to them. |
|||
Fun3 will throw an error is the argument given is not a length 1 list, or a non-list. Otherwise it will display its argument. |
|||
=={{header|C}}== |
=={{header|C}}== |