|
apply
|
The apply Function invokes a Function using the Pair values as arguments .
The function is invoked and resulting value is returned.
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:
(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 pair) The resulting value after the function is evaluated.
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. Here are also a number of links to functions having arguments with any of these data types.
You can always talk with the AIS at aiserver.sourceforge.net.
Name
Description
AIS Types function any valid function name Pair A Pair containing values and are valid arguments to the named function. Pair
Returns:
Examples
Argument Types
Structure
Vector
Matrix
Symbol
Pair
List
FltVector
IntVector
ShortVector
NumVector
CpxVector
BitVector
How do I contact the AIS team?