Zipper

final case
class Zipper[+A](lefts: Stream[A], focus: A, rights: Stream[A])

Provides a pointed stream, which is a non-empty zipper-like stream structure that tracks an index (focus) position in a stream. Focus can be moved forward and backwards through the stream, elements can be inserted before or after the focused position, and the focused item can be deleted.

Based on the pointedlist library by Jeff Wheeler.

Companion
object
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any

Value members

Concrete methods

def ap[B](f: => Zipper[A => B]): Zipper[B]
def atEnd: Boolean

Whether the focus is on the last element in the zipper.

Whether the focus is on the last element in the zipper.

def atStart: Boolean

Whether the focus is on the first element in the zipper.

Whether the focus is on the first element in the zipper.

def delete: Option[Zipper[A]]

An alias for deleteRight

An alias for deleteRight

def deleteC: Option[Zipper[A]]

An alias for deleteRightC

An alias for deleteRightC

def deleteLeft: Option[Zipper[A]]

Deletes the element at focus and moves the focus to the left. If there is no element on the left, focus is moved to the right.

Deletes the element at focus and moves the focus to the left. If there is no element on the left, focus is moved to the right.

def deleteLeftC: Option[Zipper[A]]

Deletes the focused element and moves focus to the left. If the focus was on the first element, focus is moved to the last element.

Deletes the focused element and moves focus to the left. If the focus was on the first element, focus is moved to the last element.

def deleteLeftCOr[AA >: A](z: => Zipper[AA]): Zipper[AA]

Deletes the focused element and moves focus to the left. If the focus was on the first element, focus is moved to the last element.

Deletes the focused element and moves focus to the left. If the focus was on the first element, focus is moved to the last element.

def deleteLeftOr[AA >: A](z: => Zipper[AA]): Zipper[AA]

Deletes the element at focus and moves the focus to the left. If there is no element on the left, focus is moved to the right.

Deletes the element at focus and moves the focus to the left. If there is no element on the left, focus is moved to the right.

Deletes all elements except the focused element.

Deletes all elements except the focused element.

def deleteRight: Option[Zipper[A]]

Deletes the element at focus and moves the focus to the right. If there is no element on the right, focus is moved to the left.

Deletes the element at focus and moves the focus to the right. If there is no element on the right, focus is moved to the left.

def deleteRightC: Option[Zipper[A]]

Deletes the focused element and moves focus to the right. If the focus was on the last element, focus is moved to the first element.

Deletes the focused element and moves focus to the right. If the focus was on the last element, focus is moved to the first element.

def deleteRightCOr[AA >: A](z: => Zipper[AA]): Zipper[AA]

Deletes the focused element and moves focus to the right. If the focus was on the last element, focus is moved to the first element.

Deletes the focused element and moves focus to the right. If the focus was on the last element, focus is moved to the first element.

def deleteRightOr[AA >: A](z: => Zipper[AA]): Zipper[AA]

Deletes the element at focus and moves the focus to the right. If there is no element on the right, focus is moved to the left.

Deletes the element at focus and moves the focus to the right. If there is no element on the right, focus is moved to the left.

def end: Zipper[A]

Moves focus to the end of the zipper.

Moves focus to the end of the zipper.

def findBy[AA >: A](f: Zipper[AA] => Option[Zipper[AA]])(p: AA => Boolean): Option[Zipper[AA]]

Given a traversal function, find the first element along the traversal that matches a given predicate.

Given a traversal function, find the first element along the traversal that matches a given predicate.

def findNext(p: A => Boolean): Option[Zipper[A]]

Moves focus to the nearest element on the right that matches the given predicate, or None if there is no such element.

Moves focus to the nearest element on the right that matches the given predicate, or None if there is no such element.

def findPrevious(p: A => Boolean): Option[Zipper[A]]

Moves focus to the previous element on the left that matches the given predicate, or None if there is no such element.

Moves focus to the previous element on the left that matches the given predicate, or None if there is no such element.

def findZ(p: A => Boolean): Option[Zipper[A]]

Moves focus to the nearest element matching the given predicate, preferring the left, or None if no element matches.

Moves focus to the nearest element matching the given predicate, preferring the left, or None if no element matches.

def findZor[AA >: A](p: A => Boolean, z: => Zipper[AA]): Zipper[AA]

Moves focus to the nearest element matching the given predicate, preferring the left, or the default if no element matches.

Moves focus to the nearest element matching the given predicate, preferring the left, or the default if no element matches.

def foldLeft[B](b: B)(f: (B, A) => B): B
def foldRight[B](b: => B)(f: (A, => B) => B): B
def index: Int

The index of the focus.

The index of the focus.

def insert[AA >: A]: AA => Zipper[AA]

An alias for insertRight

An alias for insertRight

def insertLeft[AA >: A](y: AA): Zipper[AA]

Inserts an element to the left of focus and focuses on the new element.

Inserts an element to the left of focus and focuses on the new element.

def insertRight[AA >: A](y: AA): Zipper[AA]

Inserts an element to the right of focus and focuses on the new element.

Inserts an element to the right of focus and focuses on the new element.

def length: Int
def map[B](f: A => B): Zipper[B]
def modify[AA >: A](f: A => AA): Zipper[AA]

Apply f to the focus and update with the result.

Apply f to the focus and update with the result.

def move(n: Int): Option[Zipper[A]]

Moves focus n elements in the zipper, or None if there is no such element.

Moves focus n elements in the zipper, or None if there is no such element.

Value Params
n

number of elements to move (positive is forward, negative is backwards)

def moveOr[AA >: A](n: Int, z: => Zipper[AA]): Zipper[AA]

Moves focus to the nth element of the zipper, or the default if there is no such element.

Moves focus to the nth element of the zipper, or the default if there is no such element.

def next: Option[Zipper[A]]

Possibly moves to next element to the right of focus.

Possibly moves to next element to the right of focus.

def nextC: Zipper[A]

Moves focus to the next element. If the last element is currently focused, loop to the first element.

Moves focus to the next element. If the last element is currently focused, loop to the first element.

def nextOr[AA >: A](z: => Zipper[AA]): Zipper[AA]

Possibly moves to next element to the right of focus.

Possibly moves to next element to the right of focus.

A zipper of all positions of the zipper, with focus on the current position.

A zipper of all positions of the zipper, with focus on the current position.

def previous: Option[Zipper[A]]

Possibly moves to the previous element to the left of focus.

Possibly moves to the previous element to the left of focus.

Moves focus to the previous element. If the first element is currently focused, loop to the last element.

Moves focus to the previous element. If the first element is currently focused, loop to the last element.

def previousOr[AA >: A](z: => Zipper[AA]): Zipper[AA]

Possibly moves to previous element to the left of focus.

Possibly moves to previous element to the left of focus.

def start: Zipper[A]

Moves focus to the start of the zipper.

Moves focus to the start of the zipper.

def toStream: Stream[A]

Get the Stream representation of this Zipper. This fully traverses lefts. rights is not evaluated.

Get the Stream representation of this Zipper. This fully traverses lefts. rights is not evaluated.

override
def toString: String
Definition Classes
Any
def traverse[G[_] : Applicative, B](f: A => G[B]): G[Zipper[B]]

Moves to the previous element to the left of focus, or error if there is no element on the left.

Moves to the previous element to the left of focus, or error if there is no element on the left.

def update[AA >: A](focus: AA): Zipper[AA]

Update the focus in this zipper.

Update the focus in this zipper.

def withFocus: Zipper[(A, Boolean)]

Pairs each element with a boolean indicating whether that element has focus.

Pairs each element with a boolean indicating whether that element has focus.

Inherited methods

def productElementNames: Iterator[String]
Inherited from
Product
def productIterator: Iterator[Any]
Inherited from
Product