Search code examples
prologunification

prolog single quote (') unification


I'm trying to unify variable X with '*' (including the quote marks, for a total of 3-symbol string) What I'm doing is a simple X='*'., but that results in X having the value *. If I go for X=''*''., the result is X=''*''. I'm confused, how can I achieve the '*'?


Solution

  • If you truly want a string, you should use double-quotes:

    X="'*'".
    

    If you want to make a symbol, you can use

    atom_codes( X, "'*'" ).