I have a base case in my predicate in which I have to assign the value that is in atom A to atom B. Not sure if this is possible but is there any way to do this?
my predicate is as below
montage(Expr,Out) :- atom(Expr), ....
From the atom(Expr) onwards, I tried various ways but nothing is right.
For example if Expr is ‘a’ and Out is ‘a11’ and Expr is an atom, Out will be assigned ‘a’ as well.
Thanks in advance for the help.
In Prolog, you don’t assign, you unify. You cannot unify
awitha11since they are distinct atoms:This also holds true for variables already bound through unification with those atoms:
In fact, when both sides of the
=clause are entirely ground (contain no variables anywhere), unification reduces to checking for term equality. That’s why you can use=both to bind variables and to do pattern matching.You’ll have to rethink your program logic to work without assignment.