=..meta-predicate, pronounced "univ", can be used to convert a list whose first item is a non-numeric atom, into a term, and vice-versa. For example,
?- Term =.. [likes, mary, pizza]. Term = likes(mary, pizza).or
?- likes(mary, pizza) =.. List. List = [likes, mary, pizza].
Here are some other examples:
?- Term =.. [this, predicate, works, with, longer, lists, too]. Term = this(predicate, works, with, longer, lists, too). ?- Term =.. [one]. Term = one. ?- Term =.. [one, two]. Term = one(two).
univ works with infix operators, too, though perhaps in a slightly unexpected way. Two examples:
?- op(700, xfy, and). true. ?- Term =.. [and, p, q]. Term = p and q ?- Expression =.. [+, 2, 3], Value is Expression. Expression = 2+3 Value = 5