Anonymous user
Call a function: Difference between revisions
no edit summary
No edit summary |
No edit summary |
||
Line 1,425:
'impossible
</lang>
=={{header|Little}}==
The following examples use buldin functions, standard Tcl commands and some
local fuctions.
<lang C>// Calling a function that requires no arguments
void foo() {puts("Calling a function with no arguments");}
foo();
// Calling a function with a fixed number of arguments
abs(-36);
// Calling a function with optional arguments
puts(nonewline: "nonewline is an optional argument");
puts("\n");
// Calling a function with a variable number of arguments
void var_arg_func(...args) {
puts(length(args));
}
var_arg_func(1, 2);
var_arg_func(1, 2, 3);
// Obtaining the return value of a function
int s = clock("seconds"); //current time in seconds
// Calling a function with named arguments
// format is a named argument in Clock_format
int str = Clock_format(s, format: "%B");
puts(str);
// Stating whether arguments are passed by value or by reference
void f(int a, int &b) { a++; b++; }
{
int a = 0;
int b = 0;
f(a, &b);
puts (a);
puts (b);
}</lang>
=={{header|Lua}}==
|