binarySearch

 

 

Overview

The binarySearch function performs a binary search for the key value in the specified Object. If a matching value is found, the index of the matching value is returned; otherwise false is returned.

Usage

When a Vector has been previously sorted in ascending order, the binarySearch function is an efficient way to determine if a specific value exists in the Vector and if exists, what location in the Vector it exists.

Structure

When a structure has been previously sorted, the binarySearch function is an efficient way to determine if a specific key exists in the structure and if exists, what location in the structure it exists.

Dictionary

When a Dictionary has been previously sorted, the binarySearch function is an efficient way to determine if a specific key exists in the Dictionary and if exists, what location in the Dictionary it exists.

Matrix

Note: Returns an error message if the Matrix is not of rank one.

When a Matrix has been previously sorted in ascending order, the binarySearch function is an efficient way to determine if a specific value exists in the Matrix and if exists, what location in the Matrix it exists.

NumMatrix

Note: Returns an error message if the Matrix is not of rank one.

When a NumMatrix has been previously sorted in ascending order, the binarySearch function is an efficient way to determine if a specific value exists in the NumMatrix and if exists, what location in the NumMatrix it exists.

 

Syntax


Expression:

(binarySearch vector searchValue)


Arguments Name Type Description
Argument:vectorVector FltVector IntVector NumVector ObjVector ShortVector A predefined Vector variable or constant.
Argument:searchValueString Text Integer value to be searched

Returns:

Returns a Boolean value false if not found. Otherwise returns a integer index of the location in the Vector where the value was found.




Expression:

(binarySearch struct searchkey)


Arguments Name Type Description
Argument:structStructure A predefined Structure variable or constant.
Argument:searchKeyString or Text A symbolic key which you want to find in the Structure.

Returns:

Returns the Boolean value false if not found. Otherwise returns a integer index of the location in the structure where the key was found.




Expression:

(binarySearch struct searchkey idsOnly)


Arguments Name Type Description
Argument:structStructure A predefined Structure variable or constant.
Argument:searchKeySymbol A symbolic key which you want to find in the Structure.
Argument:idsOnlyBoolean Value is set to false if the key comparison is to be made on object ids only (faster)

Returns:

Returns the Boolean value false if not found. Otherwise returns a integer index of the location in the structure where the key was found.




Expression:

(binarySearch dict searchkey)


Arguments Name Type Description
Argument:dictDictionary A predefined Dictionary variable or constant.
Argument:searchKeySymbol A symbolic key which you want to find in the Dictionary.

Returns:

Returns the Boolean value false if not found. Otherwise returns a integer index of the location in the dictionary where the key was found.




Expression:

(binarySearch dict searchkey idsOnly)


Arguments Name Type Description
Argument:dictDictionary A predefined Dictionary variable or constant.
Argument:searchKeySymbol A symbolic key which you want to find in the Dictionary.
Argument:idsOnlyBoolean Value is set to false if the key comparison is to be made on object ids only (faster)

Returns:

Returns the Boolean value false if not found. Otherwise returns a integer index of the location in the dictionary where the key was found.




Expression:

(binarySearch matrix searchValue)


Arguments Name Type Description
Argument:matrixMatrix A previously sorted Matrix.
Argument:searchValueString Text Integer value to be searched

Returns:

Returns a Boolean value false if not found. Otherwise returns a integer index of the location in the Matrix where the value was found.




Expression:

(binarySearch nummatrix searchValue)


Arguments Name Type Description
Argument:nummatrixNumMatrix A previously sorted NumMatrix.
Argument:searchValueString Text Integer value to be searched

Returns:

Returns a Boolean value false if not found. Otherwise returns a integer index of the location in the Vector where the value was found.



 

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.

Vector Matrix String Text
Symbol Integer Boolean FltVector
IntVector NumVector ShortVector ObjVector

Here are also a number of links to functions having arguments with any of these data types.

++ += + /=
/ *= * --
-= - abortTransaction addMethod
addi appendWriteln append apply
avg badd balance bcompareEQ
bcompareGE bcompareGT bcompareLE bcompareLT
bcompareNE bdiv beginTransaction binaryInsert
binaryNand binaryNor binaryNot binaryNxor
binarySearch bitToIntegerVector bitToNumberVector bitwiseAnd
bitwiseNand bitwiseNor bitwiseNot bitwiseNxor
bitwiseOr bitwiseShiftLeft bitwiseShiftRight bitwiseXor
bmod bmul boolean cadd
ccompareEQ ccompareGE ccompareGT ccompareLE
ccompareLT ccompareNE cdiv cdr
char character checkPointTransaction clean
clear closeLog cmod cmul
code commitTransaction compareEQ compareGE
compareGT compareLE compareLT compareNE
compare comparison compile compress
cons copy count csub
date day days360 debugBrowsableProcs
debugDetective debugEval debug defchild
defclass define(macro) define defmacro
defmethod deforphan defriend defun
deleteRows delete dimension disassemble
display divi downcase encode
evalInSyncLocalContext eval exit exportCsv
exportSbf exportTab fact fdisplay
fileClose fileCopy fileDir fileDisplay
fileEraseDir fileErase fileExists fileMakeDir
fileOpen fileReadAll fileReadRecord fileRead
fileResize fileSeek fileSizeOf fileWriteAll
fileWrite filewriteln findBlock find
floor fraction freeBlock gc
gcd getGlobalValue getRecursionCount getSymbolTable
globalBinding hashString hour iadd
icompareEQ icompareGE icompareGT icompareLE
icompareLT icompareNE idiv imod
importCsv importSbf importTab imul
insertRows insert inside inspect
integer isAtom isBitVector isBoolean
isBound isByteVector isCharAlphabetic isCharAlphanumeric
isCharLowercase isCharName isCharNumeric isCharUppercase
isCharWhitespace isChar isCharacter isComplex
isDate isDictionary isDirectory isEqual
isError isEven isExact isFloatVector
isIdentical isImmediate isInexact isInside
isIntegerVector isInteger isLambda isMatrix
isMember isMoney isNegative isNull
isNumberMatrix isNumberVector isNumber isObjectVector
isObject isOdd isPair isPcodeVector
isPositive isString isStructure isSymbol
isText isTransaction isType isVector
isZero isub julian kurtosis
lcm left length lisp
list loadModule loadWorkspace lock
logConsole macroReplace makeGramMatrix makeQuotedList
makeQuotedSymbol map mapc max
median member methodsOf mid
min minute mod modi
money month morph muli
ncompareEQ ncompareGE ncompareGT ncompareLE
ncompareLT ncompareNE new number
objectToList objectToMatrix objectToNumMatrix objectToNumVector
objectToVector offset onError openLog
pair parent parse pointer
preAllocateFixedMemoryBlocks product proplist proprecord
putprop qt quit random
randomize range rank refAttributes
refValues ref remProp remove
rename replace rept reset
resize reverse right round
run saveImmediate saveModule saveObject
saveRepository saveWorkspace second setAttributes
setBlock setCar setCdr setLastCdr
set setf setq sizeof
skew sort sql sqrt
srandom stdev stdevp stringCiEQ
stringCiGE stringCiGT stringCiLE stringCiLT
stringCiNE stringFill stringToBVector stringToVector
string subi submit substitute
substringCiEQ substringCiGE substringCiGT substringCiLE
substringCiLT substringCiNE substringEQ substringFill
substringGE substringGT substringLE substringLT
substringNE substring sum sumsqr
svmRegression symbolToTypeCode symbol systemCheck
system text time trim
type uniqueInsert unlock upcase
var varp vectorBinaryInnerProduct vectorBipolarInnerProduct
vectorCosineInnerProduct vectorCubeInnerProduct vectorDelete vectorExpInnerProduct
vectorFill vectorInnerProduct vectorLogInnerProduct vectorQuartInnerProduct
vectorQuintInnerProduct vectorSigmoidInnerProduct vectorSineInnerProduct vectorSquareInnerProduct
vectorTanInnerProduct vectorTanhInnerProduct version 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