So far, we have learned how to use functions to work with or transform other functions to process data structures or to create data types. Now, we'll finish this chapter by showing you how a function can actually implement a data type by itself, becoming a sort of container of its own. In fact, this is a basic theoretical point of the lambda calculus (and if you want to learn more, look up Church Encoding and Scott Encoding), so we may very well say that we have come back to where we began this book, at the origins of FP! We will start with a detour that considers binary trees in a different functional language, Haskell, and then move on to implementing trees as functions, but in JavaScript; this experience will help you work out how to deal with other data structures.

Mastering JavaScript Functional Programming
By :

Mastering JavaScript Functional Programming
By:
Overview of this book
Functional programming is a paradigm for developing software with better performance. It helps you write concise and testable code. To help you take your programming skills to the next level, this comprehensive book will assist you in harnessing the capabilities of functional programming with JavaScript and writing highly maintainable and testable web and server apps using functional JavaScript.
This second edition is updated and improved to cover features such as transducers, lenses, prisms and various other concepts to help you write efficient programs. By focusing on functional programming, you’ll not only start to write but also to test pure functions, and reduce side effects. The book also specifically allows you to discover techniques for simplifying code and applying recursion for loopless coding. Gradually, you’ll understand how to achieve immutability, implement design patterns, and work with data types for your application, before going on to learn functional reactive programming to handle complex events in your app. Finally, the book will take you through the design patterns that are relevant to functional programming.
By the end of this book, you’ll have developed your JavaScript skills and have gained knowledge of the essential functional programming techniques to program effectively.
Table of Contents (17 chapters)
Preface
Technical Requirements
Becoming Functional - Several Questions
Thinking Functionally - A First Example
Starting Out with Functions - A Core Concept
Behaving Properly - Pure Functions
Programming Declaratively - A Better Style
Producing Functions - Higher-Order Functions
Transforming Functions - Currying and Partial Application
Connecting Functions - Pipelining and Composition
Designing Functions - Recursion
Ensuring Purity - Immutability
Implementing Design Patterns - The Functional Way
Building Better Containers - Functional Data Types
Bibliography
Answers to Questions
Other Books You May Enjoy
How would like to rate this book
Customer Reviews