All Manuals > KnowledgeWorks and Prolog User Guide > 7 Reference Guide

findall

findallset Functions

Summary

Return all matches of a backward chaining goal.

Package

kw

Signatures

findall pattern-to-instantiate goal-to-prove => list

findallset pattern-to-instantiate goal-to-prove => set

Arguments
pattern-to-instantiate
A list or symbol.
goal-to-prove
Any backward chaining goal.
Values
list
A list.
set
A list.
Description

The function findall starts the backward chaining inference engine to look for all sets of bindings which satisfy goal-to-prove. For each of those bindings, pattern-to-instantiate is instantiated and collected to return a list. The value is nil if nothing goal-to-prove cannot be satisfied.

Any subgoals that match the object base will only find objects from the current inferencing state.

The function findallset is like findall but set will not have any duplicates (as compared by equal).

Examples
(findall '(?x is in (1 2 3)) '(member ?x (1 2 3)))

returns:

((1 IS IN (1 2 3))
 (2 IS IN (1 2 3))
 (3 IS IN (1 2 3)))
(findall '(?truck is a truck) '(truck ?truck))

returns:

((#<TRUCK TRUCK1> IS A TRUCK)
 (#<TRUCK TRUCK2> IS A TRUCK))
See also

any


KnowledgeWorks and Prolog User Guide (Unix version) - 01 Dec 2021 19:35:49