Snoc

fun interface Snoc<S, A>(source)

Snoc defines a Prism between a S and its init and last element A and thus can be seen as the reverse of Cons. It provides a way to attach or detach elements on the end side of a structure.

Parameters

S

source of Prism and init of Prism target.

A

last of Prism focus, A is supposed to be unique for a given S.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open val S.init: S?

Selects all elements except the last.

Functions

Link copied to clipboard
open fun initOption(): Optional<S, S>

Provides an Optional between S and its init S.

Link copied to clipboard
open fun lastOption(): Optional<S, A>

Provides an Optional between S and its last element A.

Link copied to clipboard
abstract fun snoc(): Prism<S, Pair<S, A>>

Provides a Prism between a S and its init and last element A.

open infix fun S.snoc(last: A): S

Append an element A to S.

Link copied to clipboard
open fun S.unsnoc(): Pair<S, A>?

Deconstruct an S between its init and last element.