diff options
author | elioat <hi@eli.li> | 2023-05-17 15:18:22 -0400 |
---|---|---|
committer | elioat <hi@eli.li> | 2023-05-17 15:18:22 -0400 |
commit | 10031290d51aac125e63d0979c31acaee36c2981 (patch) | |
tree | 05fc8f526d6a692b0d51faf4d42a51561cf664a5 /js | |
parent | 530f0f68aebb38187f419e1f802d69f438bb01e8 (diff) | |
download | tour-10031290d51aac125e63d0979c31acaee36c2981.tar.gz |
*
'
Diffstat (limited to 'js')
-rw-r--r-- | js/combinators.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/js/combinators.js b/js/combinators.js new file mode 100644 index 0000000..98ba205 --- /dev/null +++ b/js/combinators.js @@ -0,0 +1,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/ \ No newline at end of file |