User-defined functions

In an awk program, a function definition looks like this:
function name(argument-list) {
    statements
}
The argument-list is a list of one or more names (separated by commas) that represent argument values passed to the function. When an argument name is used in the statements of a function, it is replaced by a copy of the corresponding argument value.
For example, the following is a simple function that takes a single numeric argument N and returns a random integer between 1 and N (inclusive):
function random(N) {
    return (int(N * rand() + 1))
}