:COUNT
Purpose
Counts the number of values retrieved by a query.
Parameters
- ?countVariable
- A variable to be bound to the count.
- ?variable
- The variable whose bindings are to be counted.
- clause
- A non-ground clause containing ?variable.
Examples
(:COUNT ?numFriends ?friend (Friend MIKE ?friend))
(:PRINTLN "MIKE has " ?numFriends " friend(s)")
(:COUNT ?numInst ?inst (:INSTANCE Physical_Objects ?inst))
(:PRINTLN "There are " ?numInst " instances of Physical_Objects in the KB.")
Success criteria
Always succeeds. The countVariable will be zero if the
clause doesn't produce any values.
Failure criteria
Never fails.
Notes
If clause does not contain the given variable,
the countVariable will be bound to 0.
Related commands
Back to...
Algernon commands
Algernon Documentation Central
Algernon home page