This is where a goal in the body of a rule is a compound term whose functor is a
variable. By the time the goal is evaluated, the meta-variable must have been bound to
an atom.
Example
map(Pred, [], []). map(Pred, [X|Y], [X1|Y1]) :- Pred(X, X1), map(Pred, Y, Y1).
In this example, it is assumed that the meta-variable ’Pred’ will be bound to the name of a binary relation. Given the following binary relations:
double(X, Y) :-Y is X + X. square(X, Y) :-Y is X * X.You can query map/3 as follows:
map(double, [1,2,3,4], X). X = [2,4,6,8] map(square, [1,2,3,4], X). X = [1,4,9,16]