quipu-math
v1.0.0
Published
Mathematics of Incan knotted cord (quipu) data structures for JavaScript/TypeScript
Downloads
143
Maintainers
Readme
quipu-math
Mathematics of Incan knotted cord (quipu) data structures for JavaScript/TypeScript.
Quipu are Incan knotted cord recording devices. This package implements the mathematics of knotted data structures: encoding numbers as knot sequences, building cord hierarchies, arithmetic on quipus, and error detection via parity knots.
Ported from the Python quipu-math package.
Install
npm install quipu-mathUsage
import { encodeNumber, decodeKnots, Cord, CordTree, addQuipus } from "quipu-math";
// Encode a number as a knot sequence
const knots = encodeNumber(247);
// Decode back
const n = decodeKnots(knots); // 247
// Build a cord tree
const tree = new CordTree();
tree.addPendant(new Cord("red", encodeNumber(100)));
tree.addPendant(new Cord("blue", encodeNumber(47)));
// Quipu arithmetic
const result = addQuipus(tree, otherTree);API
- knot:
encodeNumber(n),decodeKnots(knots),checksum(knots) - cord:
Cordclass withaddKnot,serialize(),deserialize(json),CordTreeclass withaddPendant,traverse() - weave:
weave(cord1, cord2),unweave(cord),isAssociative(a, b, c) - arithmetic:
addQuipus(t1, t2),subtractQuipus(t1, t2),multiplyQuipus(t1, t2) - detect:
detectCorruption(original, copy)→CorruptionReport
Test
npm testMIT License
