FunctionalJ - A library for Functional Programming in Java

Copyright © 2006 Frederic Daoud, Javelot Inc.

FunctionalJ is a library which makes it easy to use functional programming constructs in Java code.

Quick links:

Send questions, comments, and suggestions to javelotinfo _at_ users.sourceforge.net.

FunctionalJ provides the following features:

  • Easily represent functions as objects
  • Code using functional programming concepts such as mapping, filtering, and folding
  • Use parameter binding, also known as partial application
  • Write methods that accept functions as parameters and/or return functions as a result (higher-order functions)
  • Replace procedural code with functional code for simpler, less error-prone computations
  • Define functions by implementing an interface, subclassing a base class, or with a reflection mechanism, according to your preference
  • Use a reflection mechanism to easily create functions that refer to existing constructors, instance methods, or static methods
  • No need to deal with exceptions if you don't want to.

Summary of what is new in version 0.8:

  • Major refactoring from version 0.7 to improve the API and provide stronger typing
  • Now available in two versions, JDK 1.4 version and new JDK 1.5 version that uses generic types and other 1.5 features
  • Pluggable reflection mechanisms
  • Two reflection mechanism implementations: one that uses the standard JDK and one that uses cglib
  • Improved documentation.


Table of Contents

1. Overview
1.1. What is FunctionalJ?
1.2. Why functional programming? Why FunctionalJ?
1.3. Quick, show me some code!
1.3.1. Does at least one object meet a certain condition?
1.3.2. Do all objects meet a certain condition?
1.3.3. Which objects meet a certain condition?
1.3.4. Apply a function to a list of objects, to obtain a list of results
1.3.5. Call a function of two parameters on corresponding objects from two lists
1.4. Summary of FunctionalJ's features
1.4.1. Defining functions
1.4.2. Parameter binding / partial application
1.4.3. Function composition
1.4.4. Reflection
1.4.5. Higher-order functions
1.4.6. Tuples
1.4.7. Utilities
1.4.8. Note about exceptions
2. Installing Functionalj
2.1. License
2.2. Downloading
2.3. Setting up
2.4. Release Notes
2.4.1. Version 0.8
2.4.2. Version 0.7.2.1
2.4.3. Version 0.7.2
2.4.4. Version 0.7.1
2.4.5. Version 0.7
3. Migrating from FunctionalJ 0.7.x to 0.8
3.1. Function interfaces
3.2. Type parameters (JDK 1.5 version)
3.3. Working with Functions
3.4. Working with tuples
3.5. Using reflection
3.6. Method differences
3.7. Using Collections instead of Lists
4. Defining functions
4.1. Function interfaces
4.2. Parameter binding / partial application
4.3. Function composition
4.4. Note about the FunctionN interface
5. Using reflection
5.1. Reflection mechanisms
5.2. Reflection elements
5.2.1. Constructors
5.2.2. Instance methods
5.2.3. Static methods
5.3. Standard reflection
5.4. Dynamic reflection
5.5. Reflection implementations
5.5.1. Finding methods by name
5.5.2. Parameter compatibility
5.5.3. Null and primitive parameters
5.5.4. Protected and private constructors and methods
6. Using higher-order functions
6.1. Mapping
6.2. Filtering
6.3. Folding
6.4. Scanning
7. Using tuples
7.1. Pairs, Triples and Quaduples
7.2. Using zip
7.3. Using unzip
7.4. Using zipWith
8. Utilities
8.1. Lists
8.1.1. Converting primitive type arrays
8.1.2. Concatenating arrays
8.1.3. Safe iteration
8.1.4. Working with parts of an array or Collection
8.2. Operators
8.3. Sorter
8.4. Strings
8.4.1. Concatenation
8.4.2. Interspersing
8.4.3. Safe length
8.4.4. String representation of an array
8.5. Utils
9. Credits
9.1. Hosting
9.2. Development
9.3. Documentation
9.4. Functional programming language
9.5. Feedback and suggestions