Hyperlinkv0.8.0-beta.28

Iterable

Iterable.prependconsteffect/Iterable.ts:221
<B>(head: B): <A>(self: Iterable<A>) => Iterable<A | B>
<A, B>(self: Iterable<A>, head: B): Iterable<A | B>

Prepends an element to the front of an Iterable, creating a new Iterable.

Example (Prepending an element)

import { Iterable } from "effect"

const numbers = [2, 3, 4]
const withOne = Iterable.prepend(numbers, 1)
console.log(Array.from(withOne)) // [1, 2, 3, 4]

// Works with any iterable
const letters = "abc"
const withZ = Iterable.prepend(letters, "z")
console.log(Array.from(withZ)) // ["z", "a", "b", "c"]
combining
export const prepend: {
  <B>(head: B): <A>(self: Iterable<A>) => Iterable<A | B>
  <A, B>(self: Iterable<A>, head: B): Iterable<A | B>
} = dual(2, <A, B>(self: Iterable<A>, head: B): Iterable<A | B> => prependAll(self, [head]))