Variadic function: Difference between revisions

no edit summary
No edit summary
Line 1,136:
<syntaxhighlight lang="lisp">(let ((arg-list '("some thing %d %d %d" 1 2 3)))
(apply 'message arg-list))</syntaxhighlight>
 
=={{header|EMal}}==
<syntaxhighlight lang="emal">
^|EMal supports variadic functions in more than one way|^
fun print = void by text mode, List args do
writeLine("== " + mode + " ==")
for each var arg in args do writeLine(arg) end
end
fun printArgumentsList = void by List args
print("accepting a list", args)
end
fun printArgumentsUnchecked = void by some var args
print("unchecked variadic", args)
end
fun printArgumentsChecked = void by text subject, logic isTrue, int howMany, some text values
print("checked variadic", var[subject, isTrue, howMany, +values]) # unary plus on lists does list expansion
end
printArgumentsList(var["These are the ", true, 7, "seas", "of", "Rhye"])
printArgumentsUnchecked("These are the ", true, 7, "seas", "of", "Rhye")
printArgumentsChecked("These are the ", true, 7, "seas", "of", "Rhye")
</syntaxhighlight>
{{out}}
<pre>
== accepting a list ==
These are the
7
seas
of
Rhye
== unchecked variadic ==
These are the
7
seas
of
Rhye
== checked variadic ==
These are the
7
seas
of
Rhye
</pre>
 
=={{header|Erlang}}==
214

edits