Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Java Functional Programming

You're reading from   Learning Java Functional Programming Create robust and maintainable Java applications using the functional style of programming

Arrow left icon
Product type Paperback
Published in Oct 2015
Publisher
ISBN-13 9781783558483
Length 296 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Richard M. Reese Richard M. Reese
Author Profile Icon Richard M. Reese
Richard M. Reese
Richard M Reese Richard M Reese
Author Profile Icon Richard M Reese
Richard M Reese
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Getting Started with Functional Programming 2. Putting the Function in Functional Programming FREE CHAPTER 3. Function Composition and Fluent Interfaces 4. Streams and the Evaluation of Expressions 5. Recursion Techniques in Java 8 6. Optional and Monads 7. Supporting Design Patterns Using Functional Programming 8. Refactoring, Debugging, and Testing 9. Bringing It All Together Index

Introduction to function composition

Function composition is concerned with combining two functions into one. For example, assume that we have two functions: f(x) and g(x). The result of composition is the creation of a third function, let's call c, such that:

    c(x) = f(g(x))

That is, the effect of calling c(x) is the same as using the output of g(x) as the input to the function f. To illustrate this approach, let's use the following definitions:

    f(x) = -x
    g(x) = 2*x
    c(5) = f(g(5)) = f(2*x) = -(2*5) = -10

The effect is that the g(x) function is called first. Its results are then used as input to the f(x) function. This capability allows more complex functions to be created in a more flexible and useful manner.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image