# Identity lists

**Author(s):**Francisco Bueno.

The operations in this module handle lists by performing equality checks via identity instead of unification.

## Usage and interface

**Library usage:**`:- use_module(library(idlists)).`**Exports:***Predicates:*`member_0/2`,`memberchk/2`,`list_insert/2`,`add_after/4`,`add_before/4`,`delete/3`,`subtract/3`,`union_idlists/3`.

## Documentation on exports

PREDICATE

**Usage:** `list_insert(List,Term)`

*Description:*Adds Term to the end of (tail-opened) List if there is not an element in List identical to Term.*The following properties should hold at call time:*

(term_typing:var/1)List is a free variable.

(term_typing:nonvar/1)Term is currently a term which is not a free variable.

PREDICATE

**Usage:** `add_after(L0,E0,E,L)`

*Description:*Adds element E after the first element identical to E0 (or at end) of list L0, returning in L the new list.*The following properties should hold at call time:*

(term_typing:nonvar/1)L0 is currently a term which is not a free variable.

(term_typing:nonvar/1)E0 is currently a term which is not a free variable.

(term_typing:nonvar/1)E is currently a term which is not a free variable.

(term_typing:var/1)L is a free variable.

PREDICATE

**Usage:** `add_before(L0,E0,E,L)`

*Description:*Adds element E before the first element identical to E0 (or at start) of list L0, returning in L the new list.*The following properties should hold at call time:*

(term_typing:nonvar/1)L0 is currently a term which is not a free variable.

(term_typing:nonvar/1)E0 is currently a term which is not a free variable.

(term_typing:nonvar/1)E is currently a term which is not a free variable.

(term_typing:var/1)L is a free variable.

PREDICATE

**Usage:** `delete(List,Element,Rest)`

*Description:*Rest has the same elements of List except for all the occurrences of elements identical to Element.*The following properties should hold at call time:*

(term_typing:nonvar/1)List is currently a term which is not a free variable.

(term_typing:nonvar/1)Element is currently a term which is not a free variable.

(term_typing:var/1)Rest is a free variable.

PREDICATE

**Usage:** `subtract(Set,Set0,Difference)`

*Description:*Difference has the same elements of Set except those which have an identical occurrence in Set0.*The following properties should hold at call time:*

(term_typing:nonvar/1)Set is currently a term which is not a free variable.

(term_typing:nonvar/1)Set0 is currently a term which is not a free variable.

(term_typing:var/1)Difference is a free variable.

PREDICATE

**Usage:** `union_idlists(List1,List2,List)`

*Description:*List has the elements which are in List1 but are not identical to an element in List2 followed by the elements in List2.*The following properties should hold at call time:*

(term_typing:nonvar/1)List1 is currently a term which is not a free variable.

(term_typing:nonvar/1)List2 is currently a term which is not a free variable.

(term_typing:var/1)List is a free variable.