offset

 

 

Overview

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.

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

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.

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

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.

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

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:(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])

 

Syntax


Expression:

(setq location (offset collection index1 index2 index3))


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:

location



 

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.

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.

++ += /= *=
-- -= addMethod appendWriteln
append apply associate balance
binaryInsert binarySearch bitToIntegerVector bitToNumberVector
bitwiseNot boolean car cdr
character class clean closeLog
code compareEQ compareGE compareGT
compareLE compareLT compareNE compare
comparison compress cons copy
count date day days360
debugBrowsableProcs debugDetective debugEval debug
decode defchild defclass define(macro)
defineStructure define defmacro defmethod
deforphan defriend defstruct defun
deleteRows delete dimension disassemble
display downcase encode evalInSyncLocalContext
eval exportCsv exportSbf exportTab
fdisplay fieldsOf fileClose fileCopy
fileDir fileDisplay fileEraseDir fileErase
fileExists fileMakeDir fileOpen fileReadAll
fileReadRecord fileRead fileSizeOf fileWriteAll
fileWrite filewriteln findBlock find
freeBlock gc getGlobalValue getSymbolTable
globalBinding hashString hour importCsv
importSbf importTab insertRows 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 julian last
left length list loadModule
loadObject loadRepository loadWorkspace lock
macroReplace makeDictionary makeGaussianMatrix makeGramMatrix
makeQuotedList makeQuotedSymbol makeStructure map
mapc matrixGaussianEliminate matrixGaussianSubstitute member
methodsOf mid minute money
month morph new number
objectToDictionary objectToDirectory objectToList objectToMatrix
objectToNumMatrix objectToNumVector objectToStructure objectToVector
offset openLog pair parent
parse pointer product proplist
proprecord putprop qt rank
refAttributes refValues ref remProp
remove rename replace rept
resize reverse right run
saveImmediate saveModule saveObject saveRepository
saveWorkspace second send setAttributes
setBlock setCar setCdr setLastCdr
set setf setq sizeof
sort sql stringCiEQ stringCiGE
stringCiGT stringCiLE stringCiLT stringCiNE
stringFill stringToBVector stringToVector string
submit substitute substringCiEQ substringCiGE
substringCiGT substringCiLE substringCiLT substringCiNE
substringEQ substringFill substringGE substringGT
substringLE substringLT substringNE substring
super svmRegression symbolToTypeCode symbol
system text time trim
type uncompress uniqueInsert unlock
upcase vectorBinaryInnerProduct vectorBipolarInnerProduct vectorCosineInnerProduct
vectorCubeInnerProduct vectorDelete vectorExpInnerProduct vectorFill
vectorInnerProduct vectorLogInnerProduct vectorQuartInnerProduct vectorQuintInnerProduct
vectorSigmoidInnerProduct vectorSineInnerProduct vectorSquareInnerProduct vectorTanInnerProduct
vectorTanhInnerProduct writelg writeln year

Analytic Information Server (AIS)

AIS Component Systems

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