R is X of Goal
Here X can be any term (usually variable) and Goal has to be an atomic goal (usually including X ). When you call this function then it calls the Goal and if it succeeds the return value will be the term with which X is bounded after this success. The function X of Y will succeed as many time as Y does.
?- write(X of p(X)), nl, fail.