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