offset
|
The offset function returns an integer offset to the specified index location within the repeating data portion of a collection object.
Usage The offset function returns an integer offset to the specified index location within the repeating data portion of a collection object.
The collection object may be of type
BitVector Brick ByteVector CpxVector Dictionary Directory FltVector IntVector
Matrix NumMatrix NumVector ObjVector Pair ShortVector String Structure Symbol Vector.
The composition of the various index arguments depend upon the type of collection object and the depth of the offset requested.
For instance the following Lisp assembler level code shows how to examine the Words in a Vector.
The pointer function is used to get the address of the repeating portion of a Vector.
The offset function is used return the Integer offset to the specified indexed location in the Vector.
Then the program displays the specified element.
A further symple example shows how to examine the Integers in an IntVector.
The pointer function is used to get the address of the repeating portion of an IntVector.
The offset function is used return the Integer offset to the specified indexed location in the IntVector.
Then the program displays the specified element.
The following example shows how to examine the elements in a NumMatrix.
The pointer function is used to get the address of the repeating portion of the NumMatrix.
The offset function is used return the Integer offset to the specified indexed location in the NumMatrix.
Then the program displays the specified element.
The following example shows how to examine the elements in a Structure.
The pointer function is used to get the address of the repeating portion of the Structure.
The offset function is used return the Integer offset to the specified indexed location in the Structure.
Then the program displays the specified element.
Note that the elements in the repeating portion of a Structure are pairs of Value and Key,
where Value is a Word and Key is an Object.
regs:(WordPointer:ptr)
vars:(Vector:x w)
(setq x (new Vector: "~" 1 2 D: 3 G:))
(setq ptr (+ (pointer x) (offset x 2)))
(writeln "x[2] = " ptr[0])
regs:(IntPointer:ptr)
vars:(Vector:x)
(setq x (new Vector: Integer: "~" 1 2 3 4 5))
(setq ptr (+ (pointer x) (offset x 3)))
(writeln "x[3] = " ptr[0])
regs:(n NumPointer:ptr)
vars:(NumMatrix:x)
(setq x (new Matrix: Number: 2 2 2 1.0 1.1 2.0 2.1))
(setq ptr (+ (pointer x) (offset x 1 1)))
(writeln "x[1 1] = " ptr[0])
regs:(WordPointer:ptr)
vars:(Structure:x)
(setq x (new Structure: A: 1.0 B: 2.0 C: 3.0 D: 4.0))
(setq ptr (+ (pointer x) (offset x C:)))
(writeln "x.C = " ptr[0])
(setq location (offset collection index1 index2 index3)) location
Expression:
Arguments
Name
Type
Description Argument: collection
BitVector Brick ByteVector CpxVector Dictionary Directory FltVector IntVector
Matrix NumMatrix NumVector ObjVector Pair ShortVector String Structure Symbol Vector
The collection object whose offset is to be returned. Argument: index1 Integer Symbol Word
The integer first index of the collection element whose offset is to be returned. Argument: index2 Integer
(Optional) The second integer index of the collection element whose offset is to be returned. Argument: index3 Integer
(Optional) The third integer index of the collection element whose offset is to be returned. Argument: location Integer
Returns the location, as an Integer offset, of the indexed element from repeating portion of the Vector specified.
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.
BitVector | Brick | ByteVector | CpxVector |
Dictionary | Directory | FltVector | IntVector |
Matrix | NumMatrix | NumVector | ObjVector |
Pair | ShortVector | String | Structure |
Symbol | Vector |
Here are also a number of links to functions having arguments with any of these data types.
Analytic Information Server (AIS)AIS Component Systems
|