diff --git a/README.md b/README.md index 23fb1ac..90c58f4 100644 --- a/README.md +++ b/README.md @@ -168,12 +168,40 @@ F combinator

finchstar :: (c -> b -> a -> d) -> a -> b -> c -> d

+F* combinator - finch once removed + +```js +> finchstar(a => separator => b => a + separator + b)('birds')('-')('fantasy') +'fantasy-birds' +``` +

finchstarstar :: (a -> d -> c -> b -> e) -> a -> b -> c -> d -> e

+F** combinator - finch twice removed. + +```js +> finchstarstar(a => postfix => b => separator => a + separator + b + postfix)('fantasy')('-')('birds')("!") +'fantasy-birds!' +``` +

goldfinch :: (b -> c -> d) -> (a -> c) -> a -> b -> d

+G combinator - goldfinch. + +```js +> goldfinch(b => c => b + c)(a => a * 2)(3)(4) +10 +``` +

hummingbird :: (a -> b -> a -> c) -> a -> b -> c

+H combinator - hummingbird. + +```js +> hummingbird(prefix => a => postfix => prefix + a + postfix)('!')('birds') +'!birds!' +``` +

idiot :: a -> a

identity @@ -185,12 +213,40 @@ identity

idstar :: (a -> b) -> a -> b

+ I* combinator - identity bird once removed - [`applicator`](#applicator--a---b---a---b) + +```js +> idstar(x => x + 1)(3) +4 +``` +

idstarstar :: (a -> b -> c) -> a -> b -> c

+I** combinator - identity bird twice removed + +```js +> idstarstar(a => b => a + b)(1)(2) +3 +``` +

jalt :: (a -> c) -> a -> b -> c

+Alternative J combinator + +```js +> jalt(a => a + 2)(1)(2) +3 +``` +

jalt_ :: (a -> b -> d) -> a -> b -> c -> d

+J' combinator + +```js +> jalt_(a => b => a * b)(1)(2)(3) +2 +``` +

jay :: (a -> b -> b) -> a -> b -> a -> b

kestrel :: a -> b -> a

@@ -204,10 +260,31 @@ K combinator or `const`

kite :: a -> b -> b

+Ki - kite. Corresponds to the encoding of `false` in the lambda calculus. + +```js +> kite(1)(3) +3 +``` +

owl :: ((a -> b) -> a) -> (a -> b) -> b

+O combinator - owl. + +```js +> owl(x => x(3))(y => y + 2) +7 +``` +

phoenix :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d

+(Big) Phi combinator - phoenix - [`starling_`](#starling_--b---c---d---a---b---a---c---a---d) + +```js +> phoenix(b => c => b - c)(a => a + 1)(a => a - 1)(5) +2 +``` +

psi :: (b -> b -> c) -> (a -> b) -> a -> a -> c

PSI combinator or on @@ -219,20 +296,76 @@ PSI combinator or on

quacky :: a -> (a -> b) -> (b -> c) -> c

+Q4 combinator - quacky bird. + +```js +> quacky(4)(a => a + 2)(b => b / 2) +3 +``` +

queer :: (a -> b) -> (b -> c) -> a -> c

+Q combinator - queer bird. + +```js +> queer(a => a + 2)(b => b * 2)(7) +18 +``` +

quirky :: (a -> b) -> a -> (b -> c) -> c

+Q3 combinator - quirky bird. + +```js +> quirky(a => a + 2)(7)(b => b * 2) +18 +``` +

quixotic :: (b -> c) -> a -> (a -> b) -> c

+Q1 combinator - quixotic bird. + +```js +> quixotic(b => b * 2)(7)(a => a + 2) +18 +``` +

quizzical :: a -> (b -> c) -> (a -> b) -> c

+Q2 combinator - quizzical bird. + +```js +> quizzical(7)(b => b * 2)(a => a + 2) +18 +``` +

robin :: a -> (b -> a -> c) -> b -> c

+R combinator - robin. + +```js +> robin("fantasy")(b => a => a + "-" + b)("birds") +'fantasy-birds' +``` +

robinstar :: (b -> c -> a -> d) -> a -> b -> c -> d

+R* combinator - robin once removed. + +```js +> robinstar( b => c => a => a + b + c )("fantasy")("-")("birds") +'fantasy-birds' +``` +

robinstarstar :: (a -> c -> d -> b -> e) -> a -> b -> c -> d -> e

+R** combinator - robin twice removed. + +```js +> robinstarstar(a => c => d => b => a + b + c + d)("fantasy")("-")("birds")("!") +'fantasy-birds!' +``` +

starling :: (a -> b -> c) -> (a -> b) -> a -> c

starling_ :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d

diff --git a/src/finchstar.js b/src/finchstar.js index 1cbcfeb..8be2be9 100644 --- a/src/finchstar.js +++ b/src/finchstar.js @@ -3,6 +3,12 @@ const curry = require('fantasy-helpers').curry //# finchstar :: (c -> b -> a -> d) -> a -> b -> c -> d //. +//. F* combinator - finch once removed +//. +//. ```js +//. > finchstar(a => separator => b => a + separator + b)('birds')('-')('fantasy') +//. 'fantasy-birds' +//. ``` const finchstar = curry((f, x, y, z) => f(z)(y)(x)) module.exports = finchstar diff --git a/src/finchstarstar.js b/src/finchstarstar.js index 05d0184..b10146a 100644 --- a/src/finchstarstar.js +++ b/src/finchstarstar.js @@ -3,6 +3,12 @@ const curry = require('fantasy-helpers').curry //# finchstarstar :: (a -> d -> c -> b -> e) -> a -> b -> c -> d -> e //. +//. F** combinator - finch twice removed. +//. +//. ```js +//. > finchstarstar(a => postfix => b => separator => a + separator + b + postfix)('fantasy')('-')('birds')("!") +//. 'fantasy-birds!' +//. ``` const finchstarstar = curry((f, s, t, u, v) => f(s)(v)(u)(t)) module.exports = finchstarstar diff --git a/src/goldfinch.js b/src/goldfinch.js index cc6a44d..8881151 100644 --- a/src/goldfinch.js +++ b/src/goldfinch.js @@ -3,6 +3,12 @@ const curry = require('fantasy-helpers').curry //# goldfinch :: (b -> c -> d) -> (a -> c) -> a -> b -> d //. +//. G combinator - goldfinch. +//. +//. ```js +//. > goldfinch(b => c => b + c)(a => a * 2)(3)(4) +//. 10 +//. ``` const goldfinch = curry((f, g, x, y) => f(y)(g(x))) module.exports = goldfinch diff --git a/src/hummingbird.js b/src/hummingbird.js index ac0e635..d197962 100644 --- a/src/hummingbird.js +++ b/src/hummingbird.js @@ -3,6 +3,13 @@ const curry = require('fantasy-helpers').curry //# hummingbird :: (a -> b -> a -> c) -> a -> b -> c //. +//. H combinator - hummingbird. +//. +//. ```js +//. > hummingbird(prefix => a => postfix => prefix + a + postfix)('!')('birds') +//. '!birds!' +//. ``` + const hummingbird = curry((f, x, y) => f(x)(y)(x)) module.exports = hummingbird diff --git a/src/idstar.js b/src/idstar.js index a5314d6..c787274 100644 --- a/src/idstar.js +++ b/src/idstar.js @@ -3,6 +3,12 @@ const curry = require('fantasy-helpers').curry //# idstar :: (a -> b) -> a -> b //. +//. I* combinator - identity bird once removed - [`applicator`](#applicator--a---b---a---b) +//. +//. ```js +//. > idstar(x => x + 1)(3) +//. 4 +//. ``` const idstar = curry((f, x) => f(x)) module.exports = idstar diff --git a/src/idstarstar.js b/src/idstarstar.js index aa18292..65b4e7e 100644 --- a/src/idstarstar.js +++ b/src/idstarstar.js @@ -3,6 +3,12 @@ const curry = require('fantasy-helpers').curry //# idstarstar :: (a -> b -> c) -> a -> b -> c //. +//. I** combinator - identity bird twice removed +//. +//. ```js +//. > idstarstar(a => b => a + b)(1)(2) +//. 3 +//. ``` const idstarstar = curry((f, x, y) => f(x)(y)) module.exports = idstarstar diff --git a/src/jalt.js b/src/jalt.js index 41792e3..e2e59bf 100644 --- a/src/jalt.js +++ b/src/jalt.js @@ -3,6 +3,12 @@ const curry = require('fantasy-helpers').curry //# jalt :: (a -> c) -> a -> b -> c //. +//. Alternative J combinator +//. +//. ```js +//. > jalt(a => a + 2)(1)(2) +//. 3 +//. ``` const jalt = curry((f, x, y) => f(x)) module.exports = jalt diff --git a/src/jalt_.js b/src/jalt_.js index d94a4ec..6bc0504 100644 --- a/src/jalt_.js +++ b/src/jalt_.js @@ -3,6 +3,12 @@ const curry = require('fantasy-helpers').curry //# jalt_ :: (a -> b -> d) -> a -> b -> c -> d //. +//. J' combinator +//. +//. ```js +//. > jalt_(a => b => a * b)(1)(2)(3) +//. 2 +//. ``` const jalt_ = curry((f, x, y, z) => f(x)(y)) module.exports = jalt_ diff --git a/src/kite.js b/src/kite.js index 2de293b..fb4e0c7 100644 --- a/src/kite.js +++ b/src/kite.js @@ -3,6 +3,12 @@ const curry = require('fantasy-helpers').curry //# kite :: a -> b -> b //. +//. Ki - kite. Corresponds to the encoding of `false` in the lambda calculus. +//. +//. ```js +//. > kite(1)(3) +//. 3 +//. ``` const kite = curry((x, y) => y) module.exports = kite diff --git a/src/owl.js b/src/owl.js index 6a53891..4c67412 100644 --- a/src/owl.js +++ b/src/owl.js @@ -3,6 +3,12 @@ const curry = require('fantasy-helpers').curry //# owl :: ((a -> b) -> a) -> (a -> b) -> b //. +//. O combinator - owl. +//. +//. ```js +//. > owl(x => x(3))(y => y + 2) +//. 7 +//. ``` const owl = curry((f, g) => g(f(g))) module.exports = owl diff --git a/src/phoenix.js b/src/phoenix.js index 95c6471..7e51736 100644 --- a/src/phoenix.js +++ b/src/phoenix.js @@ -3,6 +3,12 @@ const curry = require('fantasy-helpers').curry //# phoenix :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d //. +//. (Big) Phi combinator - phoenix - [`starling_`](#starling_--b---c---d---a---b---a---c---a---d) +//. +//. ```js +//. > phoenix(b => c => b - c)(a => a + 1)(a => a - 1)(5) +//. 2 +//. ``` const phoenix = curry((f, g, h, x) => f(g(x))(h(x))) module.exports = phoenix diff --git a/src/quacky.js b/src/quacky.js index 949a0aa..5155344 100644 --- a/src/quacky.js +++ b/src/quacky.js @@ -3,6 +3,12 @@ const curry = require('fantasy-helpers').curry //# quacky :: a -> (a -> b) -> (b -> c) -> c //. +//. Q4 combinator - quacky bird. +//. +//. ```js +//. > quacky(4)(a => a + 2)(b => b / 2) +//. 3 +//. ``` const quacky = curry((x, f, g) => g(f(x))) module.exports = quacky diff --git a/src/queer.js b/src/queer.js index 8f5481a..b460102 100644 --- a/src/queer.js +++ b/src/queer.js @@ -3,6 +3,12 @@ const curry = require('fantasy-helpers').curry //# queer :: (a -> b) -> (b -> c) -> a -> c //. +//.Q combinator - queer bird. +//. +//. ```js +//. > queer(a => a + 2)(b => b * 2)(7) +//. 18 +//. ``` const queer = curry((f, g, x) => g(f(x))) module.exports = queer diff --git a/src/quirky.js b/src/quirky.js index cd72a0b..5272aa5 100644 --- a/src/quirky.js +++ b/src/quirky.js @@ -3,6 +3,12 @@ const curry = require('fantasy-helpers').curry //# quirky :: (a -> b) -> a -> (b -> c) -> c //. +//. Q3 combinator - quirky bird. +//. +//. ```js +//. > quirky(a => a + 2)(7)(b => b * 2) +//. 18 +//. ``` const quirky = curry((f, x, g) => g(f(x))) module.exports = quirky diff --git a/src/quixotic.js b/src/quixotic.js index e58e756..b91102d 100644 --- a/src/quixotic.js +++ b/src/quixotic.js @@ -3,6 +3,12 @@ const curry = require('fantasy-helpers').curry //# quixotic :: (b -> c) -> a -> (a -> b) -> c //. +//. Q1 combinator - quixotic bird. +//. +//. ```js +//. > quixotic(b => b * 2)(7)(a => a + 2) +//. 18 +//. ``` const quixotic = curry((f, x, g) => f(g(x))) module.exports = quixotic diff --git a/src/quizzical.js b/src/quizzical.js index 4df6798..7e75a44 100644 --- a/src/quizzical.js +++ b/src/quizzical.js @@ -3,6 +3,12 @@ const curry = require('fantasy-helpers').curry //# quizzical :: a -> (b -> c) -> (a -> b) -> c //. +//. Q2 combinator - quizzical bird. +//. +//. ```js +//. > quizzical(7)(b => b * 2)(a => a + 2) +//. 18 +//. ``` const quizzical = curry((x, f, g) => f(g(x))) module.exports = quizzical diff --git a/src/robin.js b/src/robin.js index 30ac78d..b76d95d 100644 --- a/src/robin.js +++ b/src/robin.js @@ -3,6 +3,12 @@ const curry = require('fantasy-helpers').curry //# robin :: a -> (b -> a -> c) -> b -> c //. +//. R combinator - robin. +//. +//. ```js +//. > robin("fantasy")(b => a => a + "-" + b)("birds") +//. 'fantasy-birds' +//. ``` const robin = curry((x, f, y) => f(y)(x)) module.exports = robin diff --git a/src/robinstar.js b/src/robinstar.js index b7ccc30..4cfba50 100644 --- a/src/robinstar.js +++ b/src/robinstar.js @@ -3,6 +3,12 @@ const curry = require('fantasy-helpers').curry //# robinstar :: (b -> c -> a -> d) -> a -> b -> c -> d //. +//. R* combinator - robin once removed. +//. +//. ```js +//. > robinstar( b => c => a => a + b + c )("fantasy")("-")("birds") +//. 'fantasy-birds' +//. ``` const robinstar = curry((f, x, y, z) => f(y)(z)(x)) module.exports = robinstar diff --git a/src/robinstarstar.js b/src/robinstarstar.js index dbf7047..8fc6e08 100644 --- a/src/robinstarstar.js +++ b/src/robinstarstar.js @@ -3,6 +3,12 @@ const curry = require('fantasy-helpers').curry //# robinstarstar :: (a -> c -> d -> b -> e) -> a -> b -> c -> d -> e //. +//. R** combinator - robin twice removed. +//. +//. ```js +//. > robinstarstar(a => c => d => b => a + b + c + d)("fantasy")("-")("birds")("!") +//. 'fantasy-birds!' +//. ``` const robinstarstar = curry((f, s, t, u, v) => f(s)(u)(v)(t)) module.exports = robinstarstar