Posts

Showing posts with the label pattern matching

Using TotallyLazy the functional library for Java (et al.)

In software development when I revisit an imperative language, after coding in a functional language, there are many idioms that I miss. Such as pattern matching, language integrated sequence manipulation, tuples and, of course, functions-as-data... the list goes on. Languages such as Java can mimic some of these “out of the box” functional features. For example, functions-as-data can be mimicked by wrapping functions in an anonymous class, although you would still lose  function composition . Creating tuple classes is quite easy, here's an example: Tuples in Java . Pattern matching is more complicated, an implementation can be found here: Pattern Matching in Java . For “sequence manipulation” there are a number of libraries out there. One of which is TotallyLazy , which I will now document. Upon first using the library I immediately hit a wall: there are so many features that I didn't know where to begin. At that time I couldn't find any helpful guides on the Int...