Variadic function: Difference between revisions

add BQN
(add BQN)
Line 638:
little
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}}==
236

edits