![]() |
apply
|
The apply Function invokes a Function using the Vector values as arguments.
The function is invoked and resulting value is returned. This is the same as
(function ...arglist...). The apply Function invokes a Function using the structure values as arguments.
The function is invoked and resulting value is returned. This is the same as
(function ...arglist...). The apply Function invokes a Function using the Matrix values as arguments.
The function is invoked and resulting value is returned. This is the same as
(function Matrix [0] Matrix [2], etc). The apply Function invokes a Function using the NumMatrix values as arguments.
The function is invoked and resulting value is returned. This is the same as
(function NumMatrix [0] NumMatrix [2], etc). The apply Function invokes a Function using the Pair values as arguments .
The function is invoked and resulting value is returned. Usage The apply function is useful when the arguments to a function are stored
in a Vector. It shortens the amount of code to use because the apply
function eliminates the need to reference each Vector element from the Vector
to pass as an argument to the function.
The apply function is useful when the arguments to a function are stored
in a structure . It shortens the amount of code to use because the apply
function eliminates the need to reference each structure element from the structure
to pass as an argument to the function.
The apply function is useful when the arguments to a function are stored in a
Matrix. It reduces the amount of code to use because the apply function
eliminates the need to reference each Matrix element from the Matrix to pass as an
argument to the function.
The apply function is useful when the arguments to a function are stored in a
NumMatrix. It reduces the amount of code to use because the apply function
eliminates the need to reference each NumMatrix element from the NumMatrix to pass as an
argument to the function.
The apply function is typically used for Pairs represented in a List.
The apply function accesses each member of a List using integer indices 0 to
n-1 when n is the number of elements in the List. The apply function with a
List argument is equivalent to:Structure
Matrix
NumMatrix
Pair
Structure
Matrix
NumMatrix
Pair
(setq A '( 1 4 5 6 7 3 ) )
(apply + A)
or
( + (+ ( + ( + (+ A[0] A[1] ) A[2] ) A[3] ) A[4] ) A[5] )
or
(+ A[0] A[1] A [2] A[3] A[4] A[5] )
As you can see, the apply function is a much simpler form. Note that the apply function will not access the cdr (tail) of a List:
(setq A '( 1 4 5 6 7 3 . 100 ) )
(apply + A)
Returns: 26
(apply function vector) The resulting value after the function is evaluated.
(apply function struct) The resulting value after the function is evaluated.
(apply function matrix) The resulting value after the function is evaluated.
(apply function nummatrix) The resulting value after the function is evaluated.
(apply function pair) The resulting value after the function is evaluated.
Expression:
Arguments
Name
Type
Description Argument: function Word
any valid function name Argument: vector Vector FltVector IntVector NumVector BitVector ShortVector
A Vector containing values and are valid arguments to the named function.
Returns:
Expression:
Arguments
Name
Type
Description Argument: function Word
any valid function name Argument: struct Structure
A Structure containing values and are valid arguments to the named function.
Returns:
Expression:
Arguments
Name
Type
Description Argument: function Word
any valid function name Argument: matrix Matrix
A Matrix containing values and are valid arguments to the named function.
Returns:
Expression:
Arguments
Name
Type
Description Argument: function Word
any valid function name Argument: nummatrix NumMatrix
A NumMatrix containing values and are valid arguments to the named function.
Returns:
Expression:
Arguments
Name
Type
Description Argument: function Word
any valid function name Argument: Pair Pair
A Pair containing values and are valid arguments to the named function.
Returns:
Here are a number of links to Lambda coding examples which contain this instruction in various use cases.
Here are the links to the data types of the function arguments.
Structure | Vector | Matrix | Symbol |
Pair | List | FltVector | IntVector |
ShortVector | NumVector | CpxVector | BitVector |
Here are also a number of links to functions having arguments with any of these data types.
![]() |
Analytic Information Server (AIS)AIS Component Systems
|