Does anyone want to volunteer to do the inner class version one in Java?
(Note that this cannot be written in Perl or Ruby, for different reasons. Perl because you don't have lexical binding of function arguments and Ruby because it doesn't believe that you can legitimately have that many braces open.)
Cheers,
Ben