Variadic function: Difference between revisions

Content added Content deleted
(Add lang example)
Line 1,742: Line 1,742:


=={{header|Lambdatalk}}==
=={{header|Lambdatalk}}==

Lambdas are de facto variadic in lambdatalk
Lambdas are de facto variadic in lambdatalk

<syntaxhighlight lang="scheme">
<syntaxhighlight lang="scheme">
{def foo
{lambda {:s}
{if {S.empty? {S.rest :s}}
then {br}{S.first :s}
else {br}{S.first :s} {foo {S.rest :s}}}}}


{def foo
{foo hello brave new world} ->
{lambda {:s} // :s will get any sequence of words
hello
{S.first :s}
brave
{if {S.empty? {S.rest :s}} then else {foo {S.rest :s}}}}}
new
-> foo
world


{foo {S.serie 1 10}} ->
{foo hello brave new world}
-> hello brave new world
1
2
3
4
5
6
7
8
9
10


{foo {S.serie 1 10}}
-> 1 2 3 4 5 6 7 8 9 10
</syntaxhighlight>
</syntaxhighlight>