No matching definitions.

tur/zipper

stdlib/zipper.tur

typed Zipper[A]: 1D list zipper with typed focus and neighbors.

Since: Phase TC2-B

defstruct

Zipper

(defstruct Zipper [A])

parameterized 1D list zipper with element type A.

Since: Phase TC2

defn

zipper-new

(zipper-new [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.

leftpointer to left neighbor array (int64_t*); leftmost = furthest from focus
left-lennumber of elements in left
focusfocused element of type A
rightpointer to right neighbor array (int64_t*); rightmost = furthest from focus
right-lennumber 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

defn

zipper-focus

(zipper-focus [z :int])

return the focused element of a Zipper[A].

zZipper[A]

The focused element of type A.

(zipper-focus z)  ; => focused element

Since: Phase TC2

defn

zipper-move-left

(zipper-move-left [z :int])

move the focus one step to the left; returns Option[Zipper[A]].

zZipper[A]

some(new-zipper) if left neighbor exists, none otherwise.

(zipper-move-left z)  ; => some(z') or none

Since: Phase TC2

defn

zipper-move-right

(zipper-move-right [z :int])

move the focus one step to the right; returns Option[Zipper[A]].

zZipper[A]

some(new-zipper) if right neighbor exists, none otherwise.

(zipper-move-right z)  ; => some(z') or none

Since: Phase TC2

defn

zipper-free

(zipper-free [z :int])

free a Zipper[A] and its neighbor arrays.

zZipper[A] to free
(zipper-free z)

Since: Phase TC2