Mon Jan 25 10:17:12 CET 2010
Higher order functions in Java
The simplest approach seems to be to use a 'forEach' function for each
class that lifts a function. I.e. partially applied map/fold.
Currently, my main concern is to abstract database queries in Android.
There are essentially 3 main strategies to do this:
- Eagerly convert to concrete lists/arrays/...
- universal traversal function (left fold with termination)
For database traversal the Iterator abstraction isn't very good as it
doesn't have a close() method, which might leak resources. The other
two are fine.
Inversion of control ala `shift' and `reset' doesn't seem to be
straightforward to emulate, so this leaves forEach and lists, which
can be generated from forEach.