ocaml-containers/dev/containers-data/CCZipper/index.html
2021-08-02 17:37:24 +00:00

2 lines
No EOL
9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>CCZipper (containers-data.CCZipper)</title><link rel="stylesheet" href="../../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 1.5.3"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div class="content"><header><nav><a href="../index.html">Up</a> <a href="../index.html">containers-data</a> &#x00BB; CCZipper</nav><h1>Module <code>CCZipper</code></h1><h2 id="list-zipper"><a href="#list-zipper" class="anchor"></a>List Zipper</h2><dl><dt>since</dt><dd>1.0</dd></dl></header><dl><dt class="spec type" id="type-t"><a href="#type-t" class="anchor"></a><code><span class="keyword">type</span> <span>'a t</span></code><code> = <span><span class="type-var">'a</span> list</span> * <span><span class="type-var">'a</span> list</span></code></dt><dd><p>The pair <code>l, r</code> represents the list <code>List.rev_append l r</code>, but with the focus on <code>r</code></p></dd></dl><dl><dt class="spec value" id="val-empty"><a href="#val-empty" class="anchor"></a><code><span class="keyword">val</span> empty : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Empty zipper.</p></dd></dl><dl><dt class="spec value" id="val-is_empty"><a href="#val-is_empty" class="anchor"></a><code><span class="keyword">val</span> is_empty : <span><span class="type-var">_</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> bool</code></dt><dd><p>Empty zipper? Returns <code>true</code> iff the two lists are empty.</p></dd></dl><dl><dt class="spec value" id="val-to_list"><a href="#val-to_list" class="anchor"></a><code><span class="keyword">val</span> to_list : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> list</span></code></dt><dd><p>Convert the zipper back to a list. <code>to_list (l,r)</code> is <code>List.rev_append l r</code>.</p></dd></dl><dl><dt class="spec value" id="val-to_rev_list"><a href="#val-to_rev_list" class="anchor"></a><code><span class="keyword">val</span> to_rev_list : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> list</span></code></dt><dd><p>Convert the zipper back to a <i>reversed</i> list. In other words, <code>to_list (l,r)</code> is <code>List.rev_append r l</code>.</p></dd></dl><dl><dt class="spec value" id="val-make"><a href="#val-make" class="anchor"></a><code><span class="keyword">val</span> make : <span><span class="type-var">'a</span> list</span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Create a zipper pointing at the first element of the list.</p></dd></dl><dl><dt class="spec value" id="val-left"><a href="#val-left" class="anchor"></a><code><span class="keyword">val</span> left : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Go to the left, or do nothing if the zipper is already at leftmost pos.</p></dd></dl><dl><dt class="spec value" id="val-left_exn"><a href="#val-left_exn" class="anchor"></a><code><span class="keyword">val</span> left_exn : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Go to the left, or</p><dl><dt>raises Invalid_argument</dt><dd><p>if the zipper is already at leftmost pos.</p></dd></dl></dd></dl><dl><dt class="spec value" id="val-right"><a href="#val-right" class="anchor"></a><code><span class="keyword">val</span> right : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Go to the right, or do nothing if the zipper is already at rightmost pos.</p></dd></dl><dl><dt class="spec value" id="val-right_exn"><a href="#val-right_exn" class="anchor"></a><code><span class="keyword">val</span> right_exn : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Go to the right, or</p><dl><dt>raises Invalid_argument</dt><dd><p>if the zipper is already at rightmost pos.</p></dd></dl></dd></dl><dl><dt class="spec value" id="val-modify"><a href="#val-modify" class="anchor"></a><code><span class="keyword">val</span> modify : <span>(<span><span class="type-var">'a</span> option</span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> option</span>)</span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Modify the current element, if any, by returning a new element, or returning <code>None</code> if the element is to be deleted.</p></dd></dl><dl><dt class="spec value" id="val-insert"><a href="#val-insert" class="anchor"></a><code><span class="keyword">val</span> insert : <span class="type-var">'a</span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Insert an element at the current position. If an element was focused, <code>insert x l</code> adds <code>x</code> just before it, and focuses on <code>x</code>.</p></dd></dl><dl><dt class="spec value" id="val-remove"><a href="#val-remove" class="anchor"></a><code><span class="keyword">val</span> remove : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p><code>remove l</code> removes the current element, if any.</p></dd></dl><dl><dt class="spec value" id="val-is_focused"><a href="#val-is_focused" class="anchor"></a><code><span class="keyword">val</span> is_focused : <span><span class="type-var">_</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> bool</code></dt><dd><p>Is the zipper focused on some element? That is, will <a href="index.html#val-focused"><code>focused</code></a> return a <code>Some v</code>?</p></dd></dl><dl><dt class="spec value" id="val-focused"><a href="#val-focused" class="anchor"></a><code><span class="keyword">val</span> focused : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> option</span></code></dt><dd><p>Return the focused element, if any. <code>focused zip = Some _</code> iff <code>empty zip = false</code>.</p></dd></dl><dl><dt class="spec value" id="val-focused_exn"><a href="#val-focused_exn" class="anchor"></a><code><span class="keyword">val</span> focused_exn : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span class="type-var">'a</span></code></dt><dd><p>Return the focused element, or</p><dl><dt>raises Not_found</dt><dd><p>if the zipper is at an end.</p></dd></dl></dd></dl><dl><dt class="spec value" id="val-drop_before"><a href="#val-drop_before" class="anchor"></a><code><span class="keyword">val</span> drop_before : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Drop every element on the &quot;left&quot; (calling <a href="index.html#val-left"><code>left</code></a> then will do nothing).</p></dd></dl><dl><dt class="spec value" id="val-drop_after"><a href="#val-drop_after" class="anchor"></a><code><span class="keyword">val</span> drop_after : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Drop every element on the &quot;right&quot; (calling <a href="index.html#val-right"><code>right</code></a> then will do nothing), keeping the focused element, if any.</p></dd></dl><dl><dt class="spec value" id="val-drop_after_and_focused"><a href="#val-drop_after_and_focused" class="anchor"></a><code><span class="keyword">val</span> drop_after_and_focused : <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span><span class="type-var">'a</span> <a href="index.html#type-t">t</a></span></code></dt><dd><p>Drop every element on the &quot;right&quot; (calling <a href="index.html#val-right"><code>right</code></a> then will do nothing), <i>including</i> the focused element if it is present.</p></dd></dl></div></body></html>