projog

3.55. X=..L - "univ".

The X=..L predicate (pronounced "univ") provides a way to obtain the arguments of a structure as a list or construct a structure or atom from a list of arguments.

Examples

?- p(a,b,c) =.. X.
X = [p,a,b,c]

yes

?- p(a,b,c) =.. [p,a,b,c].

yes

?- p(a,b,c) =.. [p,x,y,z].

no

?- p(a,b,c) =.. [].

no

?- [a,b,c,d] =.. X.
X = [.,a,[b,c,d]]

yes

?- [a,b,c,d] =.. [X|Y].
X = .
Y = [a,[b,c,d]]

yes

?- X =.. [a,b,c,d].
X = a(b, c, d)

yes

?- X =.. [a,[b,c],d].
X = a([b,c], d)

yes

?- a+b =.. X.
X = [+,a,b]

yes

?- a+b =.. [+, X, Y].
X = a
Y = b

yes

?- a =.. [a].

yes

?- a =.. [b].

no

?- p =.. [p,x,y,z].

no

?- p(a,b,c) =.. [p].

no

?- X =.. [a].
X = a

yes

?- a+b =.. '+ X Y'.

Expected second argument to be a variable or a list but got a ATOM with value: + X Y

?- X =.. Y.

Both arguments are variables: X and: Y