package containers

  1. Overview
  2. Docs
A modular, clean and powerful extension of the OCaml standard library

Install

Dune Dependency

Authors

Maintainers

Sources

v2.8.1.tar.gz
md5=d84e09c5d0abc501aa17cd502e31a038
sha512=8b832f4ada6035e80d81be0cfb7bdffb695ec67d465ed6097a144019e2b8a8f909095e78019c3da2d8181cc3cd730cd48f7519e87d3162442562103b7f36aabb

doc/containers.data/CCZipper/index.html

Module CCZipperSource

List Zipper

  • since 1.0
Sourcetype 'a t = 'a list * 'a list

The pair l, r represents the list List.rev_append l r, but with the focus on r

Sourceval empty : 'a t

Empty zipper.

Sourceval is_empty : _ t -> bool

Empty zipper? Returns true iff the two lists are empty.

Sourceval to_list : 'a t -> 'a list

Convert the zipper back to a list. to_list (l,r) is List.rev_append l r.

Sourceval to_rev_list : 'a t -> 'a list

Convert the zipper back to a reversed list. In other words, to_list (l,r) is List.rev_append r l.

Sourceval make : 'a list -> 'a t

Create a zipper pointing at the first element of the list.

Sourceval left : 'a t -> 'a t

Go to the left, or do nothing if the zipper is already at leftmost pos.

Sourceval left_exn : 'a t -> 'a t

Go to the left, or

Sourceval right : 'a t -> 'a t

Go to the right, or do nothing if the zipper is already at rightmost pos.

Sourceval right_exn : 'a t -> 'a t

Go to the right, or

Sourceval modify : ('a option -> 'a option) -> 'a t -> 'a t

Modify the current element, if any, by returning a new element, or returning None if the element is to be deleted.

Sourceval insert : 'a -> 'a t -> 'a t

Insert an element at the current position. If an element was focused, insert x l adds x just before it, and focuses on x.

Sourceval remove : 'a t -> 'a t

remove l removes the current element, if any.

Sourceval is_focused : _ t -> bool

Is the zipper focused on some element? That is, will focused return a Some v?

Sourceval focused : 'a t -> 'a option

Return the focused element, if any. focused zip = Some _ iff empty zip = false.

Sourceval focused_exn : 'a t -> 'a

Return the focused element, or

Sourceval drop_before : 'a t -> 'a t

Drop every element on the "left" (calling left then will do nothing).

Sourceval drop_after : 'a t -> 'a t

Drop every element on the "right" (calling right then will do nothing), keeping the focused element, if any.

Sourceval drop_after_and_focused : 'a t -> 'a t

Drop every element on the "right" (calling right then will do nothing), including the focused element if it is present.

OCaml

Innovation. Community. Security.

On This Page
  1. List Zipper