Funkier Functors: Using Composite Functors

In the previous section, we used functors to filter the input to a for loop, thereby removing any need for filtering code in our processing loop. JGA has utilities for creating composite functors , and they are automatically built into every unary and binary functor. A UnaryFunctor has a compose method that returns a new functor that is a composition of an inner functor. When you see the compose method, think about the word of: f.compose(g) is like saying "f of g." In other words, you can create a functor ...

Get Wicked Cool Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.