next up previous

9.7.8.1 Testing if Any Instance-set Satisfies a Query

This function applies a query to each instance-set which matches the template. If an instance-set satisfies the query, then the function is immediately terminated, and the return value is the symbol TRUE. Otherwise, the return value is the symbol FALSE.

Syntax

(any-instancep <instance-set-template> <query>)

Example

Are there any men over age 30?

CLIPS> (any-instancep ((?man MAN)) (> ?man:age 30))
TRUE
CLIPS>

9.7.8.2 Determining the First Instance-set Satisfying a Query

This function applies a query to each instance-set which matches the template. If an instance-set satisfies the query, then the function is immediately terminated, and the instance-set is returned in a multifield value. Otherwise, the return value is a zero-length multifield value. Each field of the multifield value is an instance-name representing an instance-set member.

Syntax

(find-instance <instance-set-template> <query>)

Example

Find the first pair of a man and a woman who have the same age.

CLIPS>
(find-instance ((?m MAN) (?w WOMAN)) (= ?m:age ?w:age))
([Man-1] [Woman-1])
CLIPS>


next up previous