3 ms·
You'd use something like this when `f` and `g` are also parameters to your function. some_function(f, g, x) { var effed = f(x); var geed = g(x);
by Jtsummers 9y ago
You'd use something like this when `f` and `g` are also parameters to your function.
some_function(f, g, x) {
var effed = f(x);
var geed = g(x);
var S = effed(geed);
// some other logic
}
Not the S combinator, but consider being able to pass a comparator function to your sort function in C. Or passing an arbitrary predicate to `filter` or an arbitrary binary function/operator to `fold`. The S combinator itself may not be that useful, but higher order functions in general are very useful.
You'll also see their utility if you use tacit programming (programming without variables). Again, maybe not the explicit combinators listed here, but the mode of operating is the same. Tacit programming is easily explored through J, APL (less accessible due to the character set), the various MLs and Haskell.