zipperp — Logtalk APIs v3.47.0 documentation

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)

- Public predicates

  - `zip/2`

  - `zip/3`

  - `unzip/2`

  - `current/2`

  - `next/2`

  - `next/3`

  - `previous/2`

  - `previous/3`

  - `rewind/2`

  - `rewind/3`

  - `forward/2`

  - `forward/3`

  - `apply/2`

  - `insert_before/3`

  - `insert_after/3`

  - `replace/3`

  - `delete_and_previous/2`

  - `delete_and_next/2`

  - `delete_and_unzip/2`

  - `delete_all_before/2`

  - `delete_all_before_and_unzip/2`

  - `delete_all_after/2`

  - `delete_all_after_and_unzip/2`

- Protected predicates

- Private predicates

- Operators

## Public predicates

### `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`

### `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`

### `unzip/2`

Removes a zipper from a sequence.

Compilation flags:
`static`
Template:
`unzip(Zipper,Sequence)`
Mode and number of proofs:
`unzip(@zipper,--sequence)` - `one`

### `current/2`

Current element.

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

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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)

See also

zlist