Module list.functional.api

This file implements lists as linked lists. A list is either nil or a cons of a head value and a tail sublist. Each element of the list is a pointed pair. In a Typescript-like description :

type Nil = {}
type List<A> = Nil | Pair<A, List<A>>

Here are two different ways to create lists :

import { anyToString } from "#src/utils/printers.js";
import { cons, nil } from "#src/utils/list.functional.api.js";

const aList1 = cons(1, cons(2, nil));
anyToString(aList1); // -> (|1, 2|)

const aList2 = [1, 2, 3, 4, 5, 6, 7].reduceRight((acc, v) => cons(v, acc), nil);
anyToString(aList2); // -> (|1, 2, 3, 4, 5, 6, 7|)

Index

Variables

Functions