3 ms·
Y Combinator for Dysfunctional Non-Schemers
- brett 19y agoKind of like reading the Little Schemer and using Javascript. Which is precisely what Douglas Crockford advocates (http://javascript.crockford.com/little.html http://javascript.crockford.com/little.html - he's got an example of the Y Combinator too). Javascript's arguments.callee will also let you define anonymous recursive functions (though I realize that was not really the point of the post).
- whacked_new 19y agoVery nice article named aptly for "dysfunctional non-schemers." :) For the functional schemers/lispers out there, how close to the real picture is this? The same thing can be done in PHP, using a similar syntax, although it's probably more efficient to use switch/case (I say this because I recently rewrote some variable function names into switch/case).
- brlewis 19y agoI didn't examine each function in detail, but it looks like totally the real picture. If you have lexical scoping and anonymous functions, you have the Y combinator. I don't know if PHP has true lexical scoping and anonymous functions yet, but if it does, then yes, you can implement the Y combinator in PHP.
- ced 19y agoNice, I was always turned off by the YC explanations I found, but this did the trick. But the questions that's really not answered is: Is there anything useful for a programmer in pure CS, excluding AI? Does the ability to follow the gory papers at lambda-the-ultimate make you a better programmer (even if it is only for some obscure application)? Should I really spend a day getting intimate with the Curry-Howard isomorphism?
- mxh 19y agoI suppose it depends how much you're into formal methods, etc. The YC, for instance, was developed (if memory serves) to obviate the need for assignment WRT recursion, because assignment makes it much harder to reason about programs. In principle, CS theory can help you prove that programs are correct; Dijkstra was big on this.