Questions Concepts
GitHub icon

Variadic Functions

Variadic Functions - language feature

< >
Example from C, C++, Objective-C, Tick 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. }
Example from C3:
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);
Example from Slope:
(lambda (...) (apply + ...))
Example from Jule:
fn average(x: ...f64): f64 { // ... }

Languages with Variadic Functions include C, C++, PHP, Go, Objective-C, C3, Slope, Jule, Tick C

This question asks: Does the language support functions that accept a variable number of parameters?

Read more about Variadic Functions on the web: 1.

HTML of this page generated by Features.ts

View source

- Build the next great programming language Search Add Language Features Creators Resources About Blog Acknowledgements Queries Stats Sponsor Traffic Traffic Today Day 305 feedback@pldb.com Logout