hylomorph
v0.0.1
Published
Hylomorphism — unfold then fold.
Maintainers
Readme
hylo
A hylomorphism is an anamorphism (unfold) followed by a catamorphism (fold) — built together so the intermediate structure is never materialized.
import { hylo } from "hylo"
// factorial: unfold n → [n, n-1, ..., 1], fold with multiplication
const fact = hylo(
(x) => (x === null ? 1 : x[0] * x[1]),
(n) => (n === 0 ? null : [n, n - 1]),
)
fact(5) // 120Install
npm i hyloLicense
MIT
