下面是我总结的一些Java中函数式编程的要点,欢迎提问:
-
What is Functional Programing?
- In mathematics, function is an expression that relates an input set to an output set.
-
Functional programming
is a style of writing computer programs that treat computations as evaluating mathematical functions.
-
Lambda Calculus
-
Lambda calculus
is a universal model, a formal system to express computations based on functional abstraction. - Tremendous impact : functional programing languages implements lambda calculus.
-
Concepts of functional programing
3.1. First-Class and High-Order functions
3.2. Pure functions
3.3. Immutability
3.4. Referential transparencyFunctional programing techniques
4.1. Composition : compose(), andThen()
4.2. Monads : amonad
allows us to wrap a value, apply a set of transformations, and get the value back with all transformations applied。
such as : optional、stream、future etc, those have flatMap() method we call monad.
4.3. Currying : a mathematical technique of converting a function that takes multiple arguments into a sequence of functions that take a single argument.
Depends on : lambda expression and closures.
Closures : Java has a limitation that variables the enclosing scope have to be final or effectively final.
4.4. Recursion