.. index:: zipperp
.. _zipperp/0:

.. rst-class:: right

**protocol**

``zipperp``
===========

Zipper protocol.

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

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


| **Dependencies:**
|   (none)


| **Remarks:**
|    (none)

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

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

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

.. index:: zip/2
.. _zipperp/0::zip/2:

``zip/2``
^^^^^^^^^

Adds a zipper to a compound term holding a sequence of elements. Fails if the sequence is empty.

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

| **Template:**
|    ``zip(Sequence,Zipper)``
| **Mode and number of proofs:**
|    ``zip(+sequence,--zipper)`` - ``zero_or_one``


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

.. index:: zip/3
.. _zipperp/0::zip/3:

``zip/3``
^^^^^^^^^

Adds a zipper to a compound term holding a sequence of elements. Also returns the first element. Fails if the sequence is empty.

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

| **Template:**
|    ``zip(Sequence,Zipper,First)``
| **Mode and number of proofs:**
|    ``zip(+sequence,--zipper,--term)`` - ``zero_or_one``


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

.. index:: unzip/2
.. _zipperp/0::unzip/2:

``unzip/2``
^^^^^^^^^^^

Removes a zipper from a sequence.

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

| **Template:**
|    ``unzip(Zipper,Sequence)``
| **Mode and number of proofs:**
|    ``unzip(@zipper,--sequence)`` - ``one``


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

.. index:: current/2
.. _zipperp/0::current/2:

``current/2``
^^^^^^^^^^^^^

Current element.

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

| **Template:**
|    ``current(Zipper,Current)``
| **Mode and number of proofs:**
|    ``current(+zipper,?term)`` - ``zero_or_one``


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

.. index:: next/2
.. _zipperp/0::next/2:

``next/2``
^^^^^^^^^^

Moves to the next element. Fails if already at the last elements.

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

| **Template:**
|    ``next(Zipper,NewZipper)``
| **Mode and number of proofs:**
|    ``next(+zipper,--zipper)`` - ``zero_or_one``


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

.. index:: next/3
.. _zipperp/0::next/3:

``next/3``
^^^^^^^^^^

Moves to and returns the next element. Fails if already at the last elements.

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

| **Template:**
|    ``next(Zipper,NewZipper,Next)``
| **Mode and number of proofs:**
|    ``next(+zipper,--zipper,-term)`` - ``zero_or_one``


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

.. index:: previous/2
.. _zipperp/0::previous/2:

``previous/2``
^^^^^^^^^^^^^^

Moves to the previous element. Fails if already at the first elements.

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

| **Template:**
|    ``previous(Zipper,NewZipper)``
| **Mode and number of proofs:**
|    ``previous(+zipper,--zipper)`` - ``zero_or_one``


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

.. index:: previous/3
.. _zipperp/0::previous/3:

``previous/3``
^^^^^^^^^^^^^^

Moves to and returns the previous element. Fails if already at the first element.

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

| **Template:**
|    ``previous(Zipper,NewZipper,Previous)``
| **Mode and number of proofs:**
|    ``previous(+zipper,--zipper,-term)`` - ``zero_or_one``


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

.. index:: rewind/2
.. _zipperp/0::rewind/2:

``rewind/2``
^^^^^^^^^^^^

Rewinds the zipper so that the first element becomes the current element.

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

| **Template:**
|    ``rewind(Zipper,NewZipper)``
| **Mode and number of proofs:**
|    ``rewind(+zipper,--zipper)`` - ``one``


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

.. index:: rewind/3
.. _zipperp/0::rewind/3:

``rewind/3``
^^^^^^^^^^^^

Rewinds the zipper so that the first element becomes the current element. Also returns the first element.

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

| **Template:**
|    ``rewind(Zipper,NewZipper,First)``
| **Mode and number of proofs:**
|    ``rewind(+zipper,--zipper,?term)`` - ``zero_or_one``


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

.. index:: forward/2
.. _zipperp/0::forward/2:

``forward/2``
^^^^^^^^^^^^^

Forward the zipper so that the last element becomes the current element.

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

| **Template:**
|    ``forward(Zipper,NewZipper)``
| **Mode and number of proofs:**
|    ``forward(+zipper,--zipper)`` - ``one``


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

.. index:: forward/3
.. _zipperp/0::forward/3:

``forward/3``
^^^^^^^^^^^^^

Forward the zipper so that the last element becomes the current element. Also returns the last element.

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

| **Template:**
|    ``forward(Zipper,NewZipper,Last)``
| **Mode and number of proofs:**
|    ``forward(+zipper,--zipper,?term)`` - ``zero_or_one``


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

.. index:: apply/2
.. _zipperp/0::apply/2:

``apply/2``
^^^^^^^^^^^

Applies a closure to the current element.

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

| **Template:**
|    ``apply(Closure,Zipper)``
| **Meta-predicate template:**
|    ``apply(1,*)``
| **Mode and number of proofs:**
|    ``apply(+callable,+zipper)`` - ``zero_or_more``


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

.. index:: insert_before/3
.. _zipperp/0::insert_before/3:

``insert_before/3``
^^^^^^^^^^^^^^^^^^^

Inserts an element before the current one.

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

| **Template:**
|    ``insert_before(Zipper,Element,NewZipper)``
| **Mode and number of proofs:**
|    ``insert_before(+zipper,?term,--zipper)`` - ``zero_or_one``


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

.. index:: insert_after/3
.. _zipperp/0::insert_after/3:

``insert_after/3``
^^^^^^^^^^^^^^^^^^

Inserts an element after the current one.

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

| **Template:**
|    ``insert_after(Zipper,Element,NewZipper)``
| **Mode and number of proofs:**
|    ``insert_after(+zipper,?term,--zipper)`` - ``zero_or_one``


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

.. index:: replace/3
.. _zipperp/0::replace/3:

``replace/3``
^^^^^^^^^^^^^

Replaces the current element with a new element.

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

| **Template:**
|    ``replace(Zipper,NewCurrent,NewZipper)``
| **Mode and number of proofs:**
|    ``replace(+zipper,?term,--zipper)`` - ``one``


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

.. index:: delete_and_previous/2
.. _zipperp/0::delete_and_previous/2:

``delete_and_previous/2``
^^^^^^^^^^^^^^^^^^^^^^^^^

Deletes the current element and moves to the previous element. Fails if no previous element exists.

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

| **Template:**
|    ``delete_and_previous(Zipper,NewZipper)``
| **Mode and number of proofs:**
|    ``delete_and_previous(+zipper,--zipper)`` - ``zero_or_one``


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

.. index:: delete_and_next/2
.. _zipperp/0::delete_and_next/2:

``delete_and_next/2``
^^^^^^^^^^^^^^^^^^^^^

Deletes the current element and moves to the next element. Fails if no next element exists.

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

| **Template:**
|    ``delete_and_next(Zipper,NewZipper)``
| **Mode and number of proofs:**
|    ``delete_and_next(+zipper,--zipper)`` - ``zero_or_one``


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

.. index:: delete_and_unzip/2
.. _zipperp/0::delete_and_unzip/2:

``delete_and_unzip/2``
^^^^^^^^^^^^^^^^^^^^^^

Deletes the current element and removes the zipper returning the resulting sequence.

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

| **Template:**
|    ``delete_and_unzip(Zipper,Sequence)``
| **Mode and number of proofs:**
|    ``delete_and_unzip(+zipper,--sequence)`` - ``one``


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

.. index:: delete_all_before/2
.. _zipperp/0::delete_all_before/2:

``delete_all_before/2``
^^^^^^^^^^^^^^^^^^^^^^^

Deletes all elements before the current element.

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

| **Template:**
|    ``delete_all_before(Zipper,NewZipper)``
| **Mode and number of proofs:**
|    ``delete_all_before(+zipper,--zipper)`` - ``one``


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

.. index:: delete_all_before_and_unzip/2
.. _zipperp/0::delete_all_before_and_unzip/2:

``delete_all_before_and_unzip/2``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Deletes all elements before the current element and removes the zipper returning the resulting sequence.

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

| **Template:**
|    ``delete_all_before_and_unzip(Zipper,NewZipper)``
| **Mode and number of proofs:**
|    ``delete_all_before_and_unzip(+zipper,--sequence)`` - ``one``


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

.. index:: delete_all_after/2
.. _zipperp/0::delete_all_after/2:

``delete_all_after/2``
^^^^^^^^^^^^^^^^^^^^^^

Deletes all elements after the current element.

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

| **Template:**
|    ``delete_all_after(Zipper,NewZipper)``
| **Mode and number of proofs:**
|    ``delete_all_after(+zipper,--zipper)`` - ``one``


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

.. index:: delete_all_after_and_unzip/2
.. _zipperp/0::delete_all_after_and_unzip/2:

``delete_all_after_and_unzip/2``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Deletes all elements after the current element and removes the zipper returning the resulting sequence.

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

| **Template:**
|    ``delete_all_after_and_unzip(Zipper,NewZipper)``
| **Mode and number of proofs:**
|    ``delete_all_after_and_unzip(+zipper,--sequence)`` - ``one``


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

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

(none)

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

(none)

Operators
---------

(none)

.. seealso::

   :ref:`zlist <zlist/0>`

