PLDB
Languages Features Calendar About Lists Add Language
GitHub icon

Variadic Functions

Variadic Functions

Variadic Functions are a language feature.

In mathematics and in computer programming, a variadic function is a function of indefinite arity, i.e., one which accepts a variable number of arguments. Support for variadic functions differs widely among programming languages.. Read more on Wikipedia...

Languages with Variadic Functions include C, PHP, Go

Example from C:

double average(int count, ...) { // }

Example from PHP:

function sum(...$nums) { return array_sum($nums); } echo sum(1, 2, 3); // 6

Example from Go:

// 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. }

Article source

PLDB - Build the next great programming language 路 v2022 Docs Editor Acknowledgements Email GitHub