combinators-js
Getting Started
Install (other package managers are available):
npm i -S combinators-js
Import (other module systems are available):
Definitions
Here are the included combinators with their definitions:
const B = const B1 = const B2 = const B3 = const C = bconst C_ = dcconst C__ = cedconst D = const D1 = cconst D2 = const E = econst F = aconst F_ = cbconst F__ = edcconst G = const H = cbconst I = aconst I_ = const I__ = cconst J = cconst K = aconst L = const M = const M2 = const O = const Q = const Q1 = const Q2 = const Q3 = const Q4 = const R = aconst R_ = dbconst R__ = decconst S = const T = const U = const V = bconst V_ = bdconst V__ = ecdconst W = bconst W_ = ccconst W__ = cddconst W1 = aconst Y =
Tests
KKKKKKKKKKKKSKKKKK
Ideas
// LISP data structuresconst KI = const cons = b // manual uncurryconst car = const cdr = console // => 0console // => 1 const nil = {}const list = argsconst reverse = l === nil ? m : const reduce = === undefined ? m : const map = lnilconst length = l0const filter = lnil const arbitraryList = console // => 6 const reduced = arbitraryListnilconst filtered = reducedconst mapped = filteredconst reversed = console // => 3reversed // => 25 16 9
// recursion of anonymous functions5 // => 120 // TCO'd recursion of anonymous functions using a modified Y// taking a variadic non-combinator functionconst Y_ = 5 // => 120
// omega bird (mock a mockingbird)
Practical Ideas
¯\_(ツ)_/¯
See Also
I built a Church encoding library too.