about summary refs log tree commit diff stats
path: root/js/combinators.js
blob: 34f4698a16aae0c0e2b37f0259be7c0d4a3683a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
identity		 I	 a → a
constant		 K	 a → b → a
apply			 A	 (a → b) → a → b
thrush			 T	 a → (a → b) → b
duplication	     W	 (a → a → b) → a → b
flip			 C	 (a → b → c) → b → a → c
compose			 B	 (b → c) → (a → b) → a → c
substitution     S	 (a → b → c) → (a → b) → a → c
chain			 S_³ (a → b → c) → (b → a) → b → c
converge		 S2³ (b → c → d) → (a → b) → (a → c) → a → d
psi				 P	 (b → b → c) → (a → b) → a → a → c
fix-point4	     Y	 (a → a) → a
*/

const I  = x => x
const K  = x => y => x
const A  = f => x => f (x)
const T  = x => f => f (x)
const W  = f => x => f (x) (x)
const C  = f => y => x => f (x) (y)
const B  = f => g => x => f (g (x))
const S  = f => g => x => f (x) (g (x))
const S_ = f => g => x => f (g (x)) (x)
const S2 = f => g => h => x => f (g (x)) (h (x))
const P  = f => g => x => y => f (g (x)) (g (y))
const Y  = f => (g => g (g)) (g => f (x => g (g) (x)))

// see also
// https://ramdajs.com/
// https://sanctuary.js.org/