/S.js
Last active
April 18, 2024 11:55
Revisions
-
buzzdecafe revised this gist
Oct 16, 2016 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,20 @@ /* S : \x y z -> x z (y z) */ // S :: (z -> (a -> b)) -> (z -> a) -> z -> b function S(x, y, z) { return x(z)(y(z)); } // example: // add :: a -> a -> a function add(x) { return function(y) { return x + y; } } // mult :: a -> a function mult3(x) { return x * 3; } -
buzzdecafe created this gist
Aug 18, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ /* S : \x y z -> x z (y z) */ function S(x, y, z) { return x(z)(y(z)); } // example: function add(x) { return function(y) { return x + y; } } function mult3(x) { return x * 3; } /* S: x(z)(y(z)); x(10)(y(10)) // sub 10 for z x(10)(mult3(10)) // sub mult3 for y add(10)(30); // eval mult3(10) -> 30; sub add for x 40 // eval add(10)(30) -> 40 */ S(add, mult3, 10); // => 40 /* but what does it mean? why the S combinator? Who cares? How is it useful? Appears useful mostly for combinatory logic, not so much for real code. At least not directly. */