The successor generator.
The infinite list with applying init
to succ
.
import { successors, toIterator } from "./list.ts";
import { assertEquals } from "../deps.ts";
const iter = toIterator(successors((str: string) => str + "a")(""));
assertEquals(iter.next(), { value: "", done: false });
assertEquals(iter.next(), { value: "a", done: false });
assertEquals(iter.next(), { value: "aa", done: false });
assertEquals(iter.next(), { value: "aaa", done: false });
assertEquals(iter.next(), { value: "aaaa", done: false });
Generated using TypeDoc
Creates an infinite list with mutating by
succ
.