Skip to content

partial-order/poset

Repository files navigation

Distributive lattice of the divisors of 120
User:David_Eppstein / Public Domain

Partially ordered sets algorithms for JavaScript. See docs. Parent is js-algorithms.

import {minima} from '@partial-order/poset';
import {increasing} from '@total-order/primitive';

const a = [4, 12, 2, 6, 3];

const divides = (a, b) => b % a === 0;
const n = minima(divides, a, 0, a.length); // 2
a.slice(0, n).sort(increasing); // 2 3

const norel = (_a, _b) => false;
minima(norel, a, 0, a.length); // a.length

License Version Tests Dependencies GitHub issues Downloads

Code issues Code maintainability Code coverage (cov) Code technical debt Documentation Package size