[ Term Manipulation | Reference Manual | Alphabetic Index ]
# ?Term =.. ?List

Univ --- Succeeds if List is the list which has Term's functor as its first
element and Term's arguments, if any, as its successive elements.
*Term*
- Prolog term.
*List*
- List or variable.

## Description

If Term is atomic and/or List is a single-element list, unifies this
element with Term.
Otherwise, either Term is instantiated to a compound term, or List is
instantiated to a list, or both. In which case, ``univ'' unifies Term
with functor(Arg1, Arg2, ..., ArgN), and List with [Functor', Arg1',
Arg2', .., argN'], where functor is unified with Functor', Arg1 is
unified with Arg1', etc. functor must be an atom, and it must be
possible to determine the length of List from either Term or List.

### Modes and Determinism

- =..(+, -) is det
- =..(-, +) is det

### Exceptions

*(5) type error *
- List is instantiated, but not to a list.
*(4) instantiation fault *
- functor is not specified within Term or List (non-coroutine mode only).
*(4) instantiation fault *
- The length of List cannot be determined (non-coroutine mode only).

## Examples

Success:
Term =.. [likes,david,play]. (gives Term = likes(david,play)).
s([1,4,5,6]) =.. List. (gives List = [s,[1,4,5,6]]).
zero_arity =.. List. (gives List = [zero_arity]).
1234 =.. List. (gives List = [1234]).
"string" =.. List. (gives List = ["string"]).
2.9 =.. List. (gives List = [2.9]).
f(1,X,3) =.. [Y,Z,2,W]. (gives X=2; Y=f; Z=1; W=3).
f(1,X,3) =.. [A,B,C,D]. (gives A=f; B=1; C=2; D=3).
f(A) =.. List. (gives A=_g74; List=[f,_g74]).
Term =.. [f,A]. (gives Term=f(_g76); A=_g76).
f(1,2,3) =.. [f | A]. (gives A=[1,2,3]).
a =.. [X]. (gives X=a)
Fail:
likes(man,play) =.. [likes,man,work].
Error:
Term =.. List. (Error 4).
Term =.. [Var,1,2,3]. (Error 4). % functor of Term is
% not specified.
Term =.. [f | A]. (Error 4). % arity of Term is
% not specified.
Term =.. [f,a,b | X]. (Error 4).
Term =.. my_atom. (Error 5).
Term =.. [1,2,3]. (Error 5).
Term =.. [a|b]. (Error 5).
Term =.. [f,a,b | c]. (Error 5).

## See Also

arg / 3, arity / 2, functor / 3