[ Comparing and Sorting | Reference Manual | Alphabetic Index ]

# occurs(?Simple, ?Term)

Succeeds if Simple is a variable or an atomic type that occurs in the term Term.

Simple
  Variable or atomic type.
Term
  An arbitrary term.

## Description

Succeeds if Simple is a variable, an atom or a number occurring in the term Term.

### Modes and Determinism

- occurs(?, ?) is semidet

### Fail Conditions

Fails if Simple does not occur in the term Term.

### Exceptions

(5) type error
  If Simple is neither a variable, an atom nor a number.

## Examples

       Success:
       occurs(a,a).
       occurs(X,f(a,b,c,X)).
       occurs(+,f(+,-)).
       occurs(a,[b,c,a,g,a]).
       occurs([ ],[a,b]).
       occurs(1,[A|1]).
       occurs(1.0,[1.0|B]).
       Fail:
       occurs(a,b).
       occurs(X,f(Y,Z)).
       occurs(X,Y).
       occurs(1,"2314").
       occurs([], [a,b|c]).
       Error:
       occurs("str",f("str1","str2","str")). (Error 5)
       occurs([a],[a,b]).                    (Error 5)
       occurs(f(a,b),f(a,b)).                (Error 5)

## See Also

instance / 2, variant / 2