Skip to content

Instantly share code, notes, and snippets.

@aaditmshah
aaditmshah / queue.ts
Created August 10, 2023 09:37
Chris Okasaki's Lazy Persistent Queue
type Assert = (condition: boolean, message: string) => asserts condition;
const assert: Assert = (condition, message) => {
if (!condition) throw new Error(message);
};
type List<A> = Cons<A> | Empty;
interface Cons<out A> {
type: 'Cons';