PG on the cover of Forbes
forbes.com
forbes.com
Heh... completely wrong, but I suppose it's the best you can expect a non-techie/math nerd readership to get. Heck, it's probably close to the most you can expect the average programmer to get.
EDIT: And another one...
"Graham met Morris, an authority on the Unix computer language"
How would you explain the Y Combinator to the Hacker News readership?
(define Y
(lambda (X)
((lambda (procedure)
(X (lambda (arg) ((procedure procedure) arg))))
(lambda (procedure)
(X (lambda (arg) ((procedure procedure) arg)))))))
(define F*
(lambda (func-arg)
(lambda (n)
(if (zero? n)
1
(* n (func-arg (- n 1)))))))
(define fact (Y F*))
(write (fact 8))
Note that F* is a label for a recursive factorial-computing function without a name. // (define Y
// (lambda (X)
// ((lambda (procedure)
// (X (lambda (arg) ((procedure procedure) arg))))
// (lambda (procedure)
// (X (lambda (arg) ((procedure procedure) arg)))))))
var Y = function(X) {
return (function (procedure) {
return X(function (arg) {
return procedure(procedure)(arg);
});
})(function (procedure) {
return X(function (arg) {
return procedure(procedure)(arg);
});
});
}
// (define F*
// (lambda (func-arg)
// (lambda (n)
// (if (zero? n)
// 1
// (* n (func-arg (- n 1)))))))
var F = function(func_arg) {
return function(n) {
if (n === 0)
return 1;
else
return n * func_arg(n - 1);
};
}
// (define fact (Y F*))
var fact = Y(F);
// (write (fact 8))
console.log(fact(8)); var Y = function(X) {
var Z = X(function(arg) {
return Z(arg);
});
return Z;
} (((lambda (fact)
((lambda (f)
(fact (lambda (n) ((f f) n))))
(lambda (f)
(fact (lambda (n) ((f f) n))))))
(lambda (fact)
(lambda (n)
(if (= n 0)
1
(* n (fact (- n 1)))))))
10)
Computes 10!You'll notice that lines 6-10 define a procedure that takes a factorial function, performs one level of the recursion, and then calls the factorial function to compute the rest. The Y combinator, implemented in lines 1-5, basically allows us to start the recursion. A step by step derivation can be found at http://www.ece.uc.edu/~franco/C511/html/Scheme/ycomb.html
The really neat thing about this is that all that was required to create that factorial function was lambda, some arithmetic functions, and if. Arithmetic can be implemented using only lambdas (google church numerals) and so can if. Using these techniques you can create a factorial function using only lambda and function application (which is exactly the lambda calculus).
If you replace "program" in the Forbes article with "function" I don't think they're terribly far off.
The Y Combinator is a way to make computer code self-referential without having to introduce names for parts of the code.
Or a bit less accurate:
The Y Combinator is a clever way to make computer code self-referential.
"It's a program that lets other programs see themselves."
...but I know it's much more involved than "a program that runs other programs".
This is a good description if you're into that sort of thing: http://mvanier.livejournal.com/2897.html
The meat of it is that you can 'do' recursion by building up functions that call other functions :/ meh
Edit: Not sure why this got downvoted, but in their internal programming course they talked about the recursion problem explicitly--I'm not making this up, as crazy as it sounds.
If you don't believe me, here is a link to a blog post with someone else mentioning it in the comments:
http://htmlcoderhelper.com/what-is-the-worst-programming-lan...
edit: rather than downmod me to -1 for stating a fact, why not reply?
Possibly it makes things easier for some algorithms, but as I said, it is optional. It's not rocket science to rewrite any algorithm that relies on recursion to not need it.
I can't do it justice, but it's definitely much more interesting and even beautiful than "meh". I guess there are always "practical" vs "academic" arguments to be made but I find stuff like the lambda calculus, Y, Church numerals, all really cool.
I've always been more of a practical "why not just use a loop" kinda guy, so it's probably wasted on me.
It seems to me logical for both parties to express programs mostly using loops.
There's a lot of difference in the unoptimized form of recursion - namely stack usage. Yes you can hack together tail call recursion to try and make recursion perform as well as iteration does, but what really is the point?
Loops are a just a special case, and not really closer to the hardware. Branches and jumps are closer to the hardware. "Yes you can hack together [a compiler] to try and make [structured programming] perform as well as [goto] does, but what really is the point?"
Above is a very hard sentence to parse for non-native speakers, just saying ;)
Update: Thanks for removing the link.
Congratulations, pg. If nothing else, being on the cover of Forbes must put a smile on your face.
other than that it was guys, guys, guys. http://bit.ly/ycturgor2 has more.
It's like the leaflet I got from our local hospital the other day. It features on the cover an african, an indian, a few other minorities, and one small white person. It's like they're trying way too hard to appear diverse. (The area it serves is probably 90%+ white).
I'd rather they project what is actually out there.