Preface
1. Why
Shifting Paradigms
Aligning with Language Trends
Ceding Control to the LanguageRuntime
Concision
2. Shift
A Common Example
Imperative Processing
Functional Processing
Case Study: Number Classification
Imperative Number Classification
Slightly More Functional Number Classification
Java 8 Number Classifier
Functional Java Number Classifier
Common Building Blocks
Filter
Map
FoldReduce
Synonym Suffering
Filter
Map
FoldReduce
3. Cede
Iteration to Higher-Order Functions
Closures
Currying and Partial Application
Definitions and Distinctions
In Groovy
In Clojure
Scala
Common Uses
Recursion
Seeing Lists Differently
Streams and Work Reordering
4. Smarter, Not Harder
Memoization
Caching
Adding Memoization
Laziness
Lazy Iterator in Java
Totally Lazy Number Classifier
Lazy Lists in Groovy
Building a Lazy List
Benefits of Laziness
Lazy Field Initialization
5. Evolve
Few Data Structures, Many Operations
Bending the Language Toward the Problem
Rethinking Dispatch
Improving Dispatch with Groovy
Clojure''s "Bendable" Language
Clojure Multimethods and a la carte Polymorphism
Operator Overloading
Groovy
Scala
Functional Data Structures
Functional Error Handling
The Either Class
The Option Class
Either Trees and Pattern Matching
6. Advance...
Design Patterns in Functional Languages
Function-Level Reuse
Template Method
Strategy
The Flyweight Design Pattern and Memoization
Factory and Currying
Structural Versus Functional Reuse
Code Reuse Via Structure
8. Polyglot and Polyparadigm
Combining Functional with Metaprogramming
Mapping Data Types with Metaprogramming
Infinite Streams with Functional Java and GrooW
Consequences of Multiparadigm Languages
Context Versus Composition
Functional Pyramid
Index