matchp(expression,expression) → boolean

The subroutine matchp takes two expressions as arguments and checks whether the second expression is an instance of the first expression (the pattern). If the expression matches the pattern, matchp returns true; otherwise, it returns false.

Call: matchp(read('p(X,Y)'),read('p(a,b)')) Exit: true Call: matchp(read('p(X,Y)'),read('p(a,a)')) Exit: true Call: matchp(read('p(X,X)'),read('p(a,a)')) Exit: true Call: matchp(read('p(a,b)'),read('p(a,b)')) Exit: true Call: matchp(read('p(X,X)'),read('p(a,b)')) Exit: false User: matchp(read('p(a,b)'),read('p(X,Y)')) Exit: false

An expression is an instance of a pattern if and only of there is a variable assignment that, when applied to the pattern, produces an expression that is identical to the specified expression.

Comments and complaints to genesereth@stanford.edu.