For my programming course’s assignment, I have to write some Prolog code without using any pre-defined predicates (excluding
;), but saw no way around using
=, as I had to check whether a variable
A is equal to (can be identified with) some
Since this isn’t allowed though, I’d like to implement my own predicate
myUnification/2, which should essentially behave in the same way, but I have no idea how to go about this. I’ve tried looking at the SWI-Prolog Documentation for assistance but it only explains what the predicate does, not how it actually works internally.
It is right there in the docs 😀
To use ‘unify’ instead of ‘=’, define:
You can now do magic like this:
?- unify(X, foo(a, b)). X = foo(a, b).