tur/zipper
typed Zipper[A]: 1D list zipper with typed focus and neighbors.
Since: Phase TC2-B
Zipper
(Zipper [A] :int))
parameterized 1D list zipper with element type A.
Since: Phase TC2
zipper-new-raw
(zipper-new-raw [left ptr<void> left-len : int focus : int right ptr<void> right-len : int])
create a Zipper[A] from left array, focus, and right array.
| left | pointer to left neighbor array (int64_t*); leftmost = furthest from focus | |
| left-len | number of elements in left | |
| focus | focused element of type A | |
| right | pointer to right neighbor array (int64_t*); rightmost = furthest from focus | |
| right-len | number of elements in right |
A new Zipper[A].
(let [l (make-left-arr)
r (make-right-arr)
z (zipper-new l 2 5 r 2)]
(free l) (free r) ; caller retains l / r ownership
... use z ...
(zipper-free z)) ; frees the copies inside z
Since: Phase TC2
zipper-new
(zipper-new [A])
by-value: recover A from the typed focus element.
zipper-focus-raw
(zipper-focus-raw [z : int])
return the focused element of a Zipper[A].
| z | Zipper[A] |
The focused element of type A.
(zipper-focus z) ; => focused element
Since: Phase TC2
zipper-focus
(zipper-focus [A])
by-value: return the focused element typed as A.
zipper-move-left-raw
(zipper-move-left-raw [z : int])
move the focus one step to the left; returns Option[Zipper[A]].
| z | Zipper[A] |
some(new-zipper) if left neighbor exists, none otherwise.
(zipper-move-left z) ; => some(z') or none
Since: Phase TC2
zipper-move-left
(zipper-move-left [A])
by-value: some(z') if a left neighbor exists, else none.
zipper-move-right-raw
(zipper-move-right-raw [z : int])
move the focus one step to the right; returns Option[Zipper[A]].
| z | Zipper[A] |
some(new-zipper) if right neighbor exists, none otherwise.
(zipper-move-right z) ; => some(z') or none
Since: Phase TC2
zipper-move-right
(zipper-move-right [A])
by-value: some(z') if a right neighbor exists, else none.
zipper-free-raw
(zipper-free-raw [z : int])
free a Zipper[A] and its neighbor arrays.
| z | Zipper[A] to free |
(zipper-free z)
Since: Phase TC2
zipper-free
(zipper-free [A])
by-value: free a Zipper[A] and its neighbor arrays.