Functional Programming in Java

From:
"andrew cooke" <andrew@...>

Date:
Wed, 11 Jan 2006 07:20:05 -0300 (CLST)

(From Phil (thanks!))
FunctionalJ is a library which makes it easy to use functional programming
patterns in Java code.
FunctionalJ provides the following features:
* Easily represent functions as objects
* Dynamically invoke a constructor, instance method, or static method
* Use currying (partial function application)
* Write methods which accept functions as parameters and/or return
functions as a result (higher-order functions)
* Replace procedural code with functional code for simpler, less
error-prone computations
* Code with functional programming patterns such as mapping,
filtering, folding, scanning, and more.
http://functionalj.sourceforge.net/
Introduced at http://www.theserverside.com/news/thread.tss?thread_id=38430
There's an interesting comment from someone who had implemented a similar
library at
http://www.theserverside.com/news/thread.tss?thread_id=38430#196743 - they
found that debugging was very difficult.
This also reminded me of my attempts at something related. In the xpath
parser code I found that iterators made functional-like code very
difficult because they had internal state. So I introduced something more
like pointers/references which I called cursors. The odd thing being that
"null cursors" (used to indicate the end of a sequence, for example)
worked best if they returned random values rather than throwing
exceptions. Yes, that makes little sense to me, too - I can't remember
any more than that and the comments at
http://www.acooke.org/jara/org-acooke/org/acooke/cursor/package-summary.html
are rather cryptic...
Andrew