apply

 

 

Overview

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...).

Structure

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...).

Matrix

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).

NumMatrix

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).

Pair

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.

Structure

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.

Matrix

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.

NumMatrix

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.

Pair

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

 

Syntax


Expression:

(apply function vector)


Arguments Name Type Description
Argument:functionWord any valid function name
Argument:vectorVector FltVector IntVector NumVector BitVector ShortVector A Vector containing values and are valid arguments to the named function.

Returns:

The resulting value after the function is evaluated.




Expression:

(apply function struct)


Arguments Name Type Description
Argument:functionWord any valid function name
Argument:structStructure A Structure containing values and are valid arguments to the named function.

Returns:

The resulting value after the function is evaluated.




Expression:

(apply function matrix)


Arguments Name Type Description
Argument:functionWord any valid function name
Argument:matrixMatrix A Matrix containing values and are valid arguments to the named function.

Returns:

The resulting value after the function is evaluated.




Expression:

(apply function nummatrix)


Arguments Name Type Description
Argument:functionWord any valid function name
Argument:nummatrixNumMatrix A NumMatrix containing values and are valid arguments to the named function.

Returns:

The resulting value after the function is evaluated.




Expression:

(apply function pair)


Arguments Name Type Description
Argument:functionWord any valid function name
Argument:PairPair A Pair containing values and are valid arguments to the named function.

Returns:

The resulting value after the function is evaluated.



 

Examples

Here are a number of links to Lambda coding examples which contain this instruction in various use cases.

 

Argument Types

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.

++ += /= *=
-- -= addMethod appendWriteln
append apply associate binaryInsert
binarySearch bitToIntegerVector bitToNumberVector boolean
c::r car cdr character
class compareEQ compareGE compareGT
compareLE compareLT compareNE compare
comparison compile compress cons
copy count debugDetective debug
defchild defclass define(macro) defineStructure
define defmacro defmethod deforphan
defriend defstruct defun delete
dimension disassemble display downcase
encode eval exportCsv exportSbf
exportTab fieldsOf findBlock find
freeBlock gc getGlobalValue getSymbolTable
globalBinding importCsv importSbf importTab
insert inside inspect integer
isAtom isBitVector isBoolean isBound
isByteVector isCharAlphabetic isCharAlphanumeric isCharLowercase
isCharName isCharNumeric isCharUppercase isCharWhitespace
isChar isCharacter isClass isComplex
isDate isDictionary isDirectory isEqual
isError isFloatVector isIdentical isInside
isIntegerVector isInteger isLambda isMatrix
isMember isMoney isNumberMatrix isNumberVector
isNumber isObjectVector isObject isPair
isPcodeVector isString isStructure isSymbol
isText isType isVector last
length lisp list lock
macroReplace makeGramMatrix makeQuotedList makeQuotedSymbol
makeStructure map mapc member
methodsOf money morph new
number objectToList objectToMatrix objectToNumMatrix
objectToNumVector objectToStructure objectToVector offset
openLog pair parent parse
pointer product proplist proprecord
putprop qt quote rank
refAttributes refValues ref remProp
remove rename resize reverse
saveObject saveRepository send setAttributes
setBlock setCar setCdr setLastCdr
set setf setq sizeof
sort sql stringToBVector stringToVector
string super svmRegression symbolToTypeCode
symbol type uniqueInsert unlock
vectorBinaryInnerProduct vectorBipolarInnerProduct vectorCosineInnerProduct vectorCubeInnerProduct
vectorExpInnerProduct vectorFill vectorInnerProduct vectorLogInnerProduct
vectorQuartInnerProduct vectorQuintInnerProduct vectorSigmoidInnerProduct vectorSineInnerProduct
vectorSquareInnerProduct vectorTanInnerProduct vectorTanhInnerProduct writelg
writeln

Analytic Information Server (AIS)

AIS Component Systems

  • Smartbase Engine
  • QT C++ Libraries
  • MySQL Relational Database
  • AIS Lisp Libraries
  • Rapid Analytic Demo IDE