associate

 

 

Overview

The associate funtion returns the first pair in a List {list} of Pairs whose car component matches the object key {key}. If no Pair in the target List has a car component matching the key, then false is returned. The target must be a List each of whose elements are Pairs.

Usage

The associate function is used to find the Pair of a specific key.

For instance the following Lisp code shows how to built a List of Pairs, and then how to find the Pair associated with the specified key.

(setq trees '((pine . cones) (oak . acorns) (maple . seeds))) ;; == >((pine . cones) (oak . acorns) (maple . seeds))
(associate 'oak trees) ;; ==> (oak . acorns)
(cdr (associate 'oak trees)) ;; ==> acorns
(associate 'birch trees) ;; ==> false

 

Syntax


Expression:

(associate key list) ;; Return the Pair associated with the key in the list


Arguments Name Type Description
Argument:keyWord The key whose associate is to be returned
Argument:listPair The List of Pairs where the car is the key and the cdr is the associated value.

Returns:

Return the Pair associated with the key in the list - or false.



 

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.

Pair List

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

addMethod append apply associate
boolean c::r car cdr
compareEQ compareGE compareGT compareLE
compareLT compareNE compare compile
copy count delete dimension
display eval integer isAtom
isComplex isDate isEqual isError
isIdentical isInteger isMoney isNumber
isObject isPair isType last
length lisp list macroReplace
makeQuotedList map mapc member
money morph number objectToList
objectToMatrix objectToNumMatrix objectToNumVector objectToVector
offset pair pointer proplist
proprecord putprop quote ref
remProp reverse saveObject setCar
setCdr setLastCdr setq sizeof
sort string type writelg
writeln

Analytic Information Server (AIS)

AIS Component Systems

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