3 ms·
It can be done. But it's not pretty. Cumbersome and verbose.
by eru 18y ago
It can be done. But it's not pretty. Cumbersome and verbose.
- gaius 18y agoAnd the libraries are full of side effects.
- speek 18y agoWho needs libraries for non-destructive programming in java? You can just use an interface for a list of T (ILoT), a representation of an empty list (MtLoT), and a ConsLoT which has a first (which is of the type T) and a rest (which is of the type ILoT). Bam, you've got a list implementation ( new ConsLoT(new T(arg1, arg2, argN), new ConsLoT(new T(argA, argB, argN), new MtLoT)); ). Function objects are a little different though (http://en.wikipedia.org/wiki/Function_object#Functors_in_Java http://en.wikipedia.org/wiki/Function_object#Functors_in_Jav...).
- eru 18y agoWhy are you so fixated on lists? There is more to functional programming than that.