Next Prev Up Top Contents Index

with-rule-actions

Macro
Syntax

with-rule-actions bound-variables &body body

Arguments

bound-variables is a list of variables (each starting with ? ) which are already bound. body is a rule body consisting of the same kind of statements that make up the right hand side of a forward or backward chaining rule.

Description

This macro enables rule syntax to be embedded within Lisp. The body is executed just as if it were the right hand side of a rule. All variables in the body (denoted by ? ) are taken to be unbound unless found in the list bound-variables in which case its value is taken from the Lisp variable of the same name. It is similar to the function any but can be compiled for efficiency.

Values

T if the body succeeds (that is, all statements are successfully executed), else nil (if the statements fail).

Example
(defun my-fn (?x)
  "prints all the lists which append to give ?x and
   then returns NIL"
  (with-rule-actions (?x)
    (append ?a ?b ?x)
    ((format t "~%~S and ~S append to give ~S"
             ?a ?b ?x))
    (fail)))
See Also

any

 


LispWorks KnowledgeWorks and Prolog User Guide - 14 Dec 2001

Next Prev Up Top Contents Index