double average(int count, ...)
{
//
}
function sum(...$nums)
{
return array_sum($nums);
}
echo sum(1, 2, 3); // 6
// This variadic function takes an arbitrary number of ints as arguments.
func sum(nums ...int) {
fmt.Print("The sum of ", nums) // Also a variadic function.
total := 0
for _, num := range nums {
total += num
}
fmt.Println(" is", total) // Also a variadic function.
}
fn void foo_typed(int x, int... arg) { ... }
fn void foo_untyped(int x, ...arg)
...
foo_typed(1, 2, 3);
foo_untyped(1, "hello", 1.2);
(lambda (...) (apply + ...))
fn average(x: ...f64): f64 {
// ...
}
Languages with Variadic Functions include C, PHP, Go, C3, Slope, Jule
View all concepts with or missing a hasVariadicFunctions measurement
Read more about Variadic Functions on the web: 1.