From 7aa11b7a8abacf81dec20fff21216df35d333756 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sun, 27 Jul 2025 18:50:33 -0700 Subject: Pulls in pengueno from npm --- u/types/collections/cons.ts | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 u/types/collections/cons.ts (limited to 'u/types/collections/cons.ts') diff --git a/u/types/collections/cons.ts b/u/types/collections/cons.ts deleted file mode 100644 index 05dbe7c..0000000 --- a/u/types/collections/cons.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { IOptional, Mapper, Optional } from '@emprespresso/pengueno'; - -export interface ICons extends Iterable { - readonly value: T; - readonly next: IOptional>; - - readonly replace: Mapper>; - readonly before: Mapper>, ICons>; -} - -export class Cons implements ICons { - constructor( - public readonly value: T, - public readonly next: IOptional> = Optional.none(), - ) {} - - public before(head: IOptional>): ICons { - return new Cons(this.value, head); - } - - public replace(_value: T): ICons { - return new Cons(_value, this.next); - } - - *[Symbol.iterator]() { - for (let cur = Optional.some>(this); cur.present(); cur = cur.flatMap((cur) => cur.next)) { - yield cur.get().value; - } - } - - static addOnto(items: Iterable, tail: IOptional>): IOptional> { - return Array.from(items) - .reverse() - .reduce((cons, value) => Optional.from>(new Cons(value, cons)), tail); - } - - static from(items: Iterable): IOptional> { - return Cons.addOnto(items, Optional.none()); - } -} -- cgit v1.2.3-70-g09d2