.. index:: varlistp
.. _varlistp/0:

.. rst-class:: right

**protocol**

``varlistp``
============

List of variables protocol.

| **Author:** Paulo Moura
| **Version:** 1:2:0
| **Date:** 2019-01-03

| **Compilation flags:**
|    ``static``


| **Dependencies:**
|   (none)


| **Remarks:**
|    (none)

| **Inherited public predicates:**
|    (none)

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

.. raw:: html

   <div id="append/3"> </div>

.. index:: append/3
.. _varlistp/0::append/3:

``append/3``
^^^^^^^^^^^^

Appends two lists.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``append(List1,List2,List)``
| **Mode and number of proofs:**
|    ``append(?list,?list,?list)`` - ``zero_or_more``


------------

.. raw:: html

   <div id="delete/3"> </div>

.. index:: delete/3
.. _varlistp/0::delete/3:

``delete/3``
^^^^^^^^^^^^

Deletes from a list all occurrences of an element returning the list of remaining elements.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``delete(List,Element,Remaining)``
| **Mode and number of proofs:**
|    ``delete(@list,@term,?list)`` - ``one``


------------

.. raw:: html

   <div id="empty/1"> </div>

.. index:: empty/1
.. _varlistp/0::empty/1:

``empty/1``
^^^^^^^^^^^

True if the argument is an empty list.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``empty(List)``
| **Mode and number of proofs:**
|    ``empty(@list)`` - ``zero_or_one``


------------

.. raw:: html

   <div id="flatten/2"> </div>

.. index:: flatten/2
.. _varlistp/0::flatten/2:

``flatten/2``
^^^^^^^^^^^^^

Flattens a list of lists into a list.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``flatten(List,Flatted)``
| **Mode and number of proofs:**
|    ``flatten(@list,-list)`` - ``one``


------------

.. raw:: html

   <div id="last/2"> </div>

.. index:: last/2
.. _varlistp/0::last/2:

``last/2``
^^^^^^^^^^

List last element (if it exists).

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``last(List,Last)``
| **Mode and number of proofs:**
|    ``last(@list,@var)`` - ``zero_or_one``


------------

.. raw:: html

   <div id="length/2"> </div>

.. index:: length/2
.. _varlistp/0::length/2:

``length/2``
^^^^^^^^^^^^

List length.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``length(List,Length)``
| **Mode and number of proofs:**
|    ``length(@list,?integer)`` - ``zero_or_one``


------------

.. raw:: html

   <div id="memberchk/2"> </div>

.. index:: memberchk/2
.. _varlistp/0::memberchk/2:

``memberchk/2``
^^^^^^^^^^^^^^^

Checks if a variable is a member of a list.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``memberchk(Element,List)``
| **Mode and number of proofs:**
|    ``memberchk(@var,@list)`` - ``zero_or_one``


------------

.. raw:: html

   <div id="nextto/3"> </div>

.. index:: nextto/3
.. _varlistp/0::nextto/3:

``nextto/3``
^^^^^^^^^^^^

``X`` and ``Y`` are consecutive elements in List.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``nextto(X,Y,List)``
| **Mode and number of proofs:**
|    ``nextto(@var,@var,?list)`` - ``zero_or_more``


------------

.. raw:: html

   <div id="nth0/3"> </div>

.. index:: nth0/3
.. _varlistp/0::nth0/3:

``nth0/3``
^^^^^^^^^^

Nth element of a list (counting from zero).

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``nth0(Nth,List,Element)``
| **Mode and number of proofs:**
|    ``nth0(?integer,+list,@var)`` - ``zero_or_more``


------------

.. raw:: html

   <div id="nth0/4"> </div>

.. index:: nth0/4
.. _varlistp/0::nth0/4:

``nth0/4``
^^^^^^^^^^

Nth element of a list (counting from zero). Can be used to either select the nth element of ``List`` or to insert an element before the nth element in ``Rest``.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``nth0(Nth,List,Element,Rest)``
| **Mode and number of proofs:**
|    ``nth0(?integer,+list,@var,?list)`` - ``zero_or_more``


------------

.. raw:: html

   <div id="nth1/3"> </div>

.. index:: nth1/3
.. _varlistp/0::nth1/3:

``nth1/3``
^^^^^^^^^^

Nth element of a list (counting from one).

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``nth1(Nth,List,Element)``
| **Mode and number of proofs:**
|    ``nth1(?integer,+list,@var)`` - ``zero_or_more``


------------

.. raw:: html

   <div id="nth1/4"> </div>

.. index:: nth1/4
.. _varlistp/0::nth1/4:

``nth1/4``
^^^^^^^^^^

Nth element of a list (counting from zero). Can be used to either select the nth element of ``List`` or to insert an element before the nth element in ``Rest``.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``nth1(Nth,List,Element,Rest)``
| **Mode and number of proofs:**
|    ``nth1(?integer,+list,@var,?list)`` - ``zero_or_more``


------------

.. raw:: html

   <div id="permutation/2"> </div>

.. index:: permutation/2
.. _varlistp/0::permutation/2:

``permutation/2``
^^^^^^^^^^^^^^^^^

The two lists are a permutation of the same list.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``permutation(List,Permutation)``
| **Mode and number of proofs:**
|    ``permutation(@list,@list)`` - ``zero_or_one``


------------

.. raw:: html

   <div id="prefix/2"> </div>

.. index:: prefix/2
.. _varlistp/0::prefix/2:

``prefix/2``
^^^^^^^^^^^^

``Prefix`` is a prefix of ``List``.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``prefix(Prefix,List)``
| **Mode and number of proofs:**
|    ``prefix(?list,@list)`` - ``zero_or_more``


------------

.. raw:: html

   <div id="remove_duplicates/2"> </div>

.. index:: remove_duplicates/2
.. _varlistp/0::remove_duplicates/2:

``remove_duplicates/2``
^^^^^^^^^^^^^^^^^^^^^^^

Removes duplicated variables and keeping the left-most variable when repeated.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``remove_duplicates(List,Set)``

------------

.. raw:: html

   <div id="reverse/2"> </div>

.. index:: reverse/2
.. _varlistp/0::reverse/2:

``reverse/2``
^^^^^^^^^^^^^

Reverses a list.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``reverse(List,Reversed)``
| **Mode and number of proofs:**
|    ``reverse(+list,-list)`` - ``one``
|    ``reverse(@list,?list)`` - ``zero_or_one``
|    ``reverse(?list,@list)`` - ``zero_or_one``
|    ``reverse(-list,-list)`` - ``one_or_more``


------------

.. raw:: html

   <div id="same_length/2"> </div>

.. index:: same_length/2
.. _varlistp/0::same_length/2:

``same_length/2``
^^^^^^^^^^^^^^^^^

The two lists have the same length.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``same_length(List1,List2)``
| **Mode and number of proofs:**
|    ``same_length(@list,?list)`` - ``zero_or_one``
|    ``same_length(?list,@list)`` - ``zero_or_one``
|    ``same_length(-list,-list)`` - ``one_or_more``


------------

.. raw:: html

   <div id="select/3"> </div>

.. index:: select/3
.. _varlistp/0::select/3:

``select/3``
^^^^^^^^^^^^

Selects an element from a list, returning the list of remaining elements.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``select(Element,List,Remaining)``
| **Mode and number of proofs:**
|    ``select(@var,?list,?list)`` - ``zero_or_more``


------------

.. raw:: html

   <div id="sublist/2"> </div>

.. index:: sublist/2
.. _varlistp/0::sublist/2:

``sublist/2``
^^^^^^^^^^^^^

The first list is a sublist of the second.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``sublist(Sublist,List)``
| **Mode and number of proofs:**
|    ``sublist(?list,@list)`` - ``zero_or_more``


------------

.. raw:: html

   <div id="subtract/3"> </div>

.. index:: subtract/3
.. _varlistp/0::subtract/3:

``subtract/3``
^^^^^^^^^^^^^^

Removes all elements in the second list from the first list, returning the list of remaining elements.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``subtract(List,Elements,Remaining)``
| **Mode and number of proofs:**
|    ``subtract(@list,@list,-list)`` - ``one``


------------

.. raw:: html

   <div id="suffix/2"> </div>

.. index:: suffix/2
.. _varlistp/0::suffix/2:

``suffix/2``
^^^^^^^^^^^^

``Suffix`` is a suffix of ``List``.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``suffix(Suffix,List)``
| **Mode and number of proofs:**
|    ``suffix(?list,@list)`` - ``zero_or_more``


------------

.. raw:: html

   <div id="valid/1"> </div>

.. index:: valid/1
.. _varlistp/0::valid/1:

``valid/1``
^^^^^^^^^^^

Term is a valid list of variables.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``valid(Term)``
| **Mode and number of proofs:**
|    ``valid(@nonvar)`` - ``zero_or_one``


------------

.. raw:: html

   <div id="check/1"> </div>

.. index:: check/1
.. _varlistp/0::check/1:

``check/1``
^^^^^^^^^^^

Checks if a term is a valid list of variables. Throws an exception if the term is not valid.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``check(Term)``
| **Mode and number of proofs:**
|    ``check(@nonvar)`` - ``one``


------------

Protected predicates
--------------------

(none)

Private predicates
------------------

(none)

Operators
---------

(none)

.. seealso::

   :ref:`varlist <varlist/0>`, :ref:`listp <listp/0>`, :ref:`numberlistp <numberlistp/0>`

