Functional Programming in Ruby
This book is 10% complete
Last updated on 2014-04-17
About the Book
This book teaches you not about what functional programming is. The target of this book is to help the reader to learn to think differently. Learning to program with a functional style will require you to do some rewiring in the brain.
Instead this book helps you to un-learn some of the patterns you've been so very much used to, and learn new functional programming based patterns that help you build consise and efficient solutions to everyday programming problems. At the same time, it will put things in perspective and put functional programming in context, and discuss the limitations of functional programming in general and in Ruby specificially.
The end goal is that this book should help the reader to become a better programmer. A better programmer for me is someone who's flexible in approaching the problem domain. I'm a strong believer that in the near future, it's going to be more and more key for a developer to know many programming languages and many programming styles.
That's also one of the reasons why I think Ruby is a good programming language to learn about functional programming style. It's far from perfect. It's not at all pure. It has limitations. But it allows you to mix and match different programming styles.
Table of Contents
-
Introduction
- Continues Integration
- Goal of this book
-
Getting Started
-
‘For’ considered Harmful
- Diving in with an Example
- Comparing Styles
- Conclusions
- Short History of Functional Programming
- The world of functional programming languages
-
The Power of Recursion
- The beauty of Recursion
- A study of faculty
- Divide and concquer
- Basic Math through recursion
- Comparing styles
- Typical list operations
-
‘For’ considered Harmful
-
Think Different
-
Different styles of Functions in Ruby
- Defs
- Lambda’s
- Short Lambda’s
- Lambda’s as constants
-
Functional Patterns in Standard Ruby
- Functions as the Atoms of an Interface
- Why Bang means Watch Out (Imutable)
- Iterator and Visitor Revisited
- No more Factory Method, Strategy, Template Method
-
Pulling your data through the blender
- Functional processing of data: Filter-Sort-Map-Reduce
- Group-Theory: Permutations-Combinations-Products
-
Advanced Recursion
- Sorting Algorithms
- Backtracking Algorithms
- Recursive Data Structures
- linkedlist
- tree
- graph
-
Different styles of Functions in Ruby
-
More Purity in your thoughts
-
Combining Functions into Programs
- What’s in a name?
- Default Parameters and Partial Evoluation
- Combining Functions into Programs
-
Advanced Data Processing
- Infinite Data Structures and laziness
- List Comprehensions
- Constraint Programming
-
Building our own
Prelude
- Basic Prelude
- Math Prelude
- List Prelude
- Text Prelude
- Revisiting prior Examples
- Coming back to the basic algorithms
- Backtracking algorithms: rewrite
-
What you are missing in Ruby (and workarounds)
- Pattern matching
- Lazy evaluation
-
Combining Functions into Programs
-
In the field
-
- Testing functional code
- Mixing styles
- Performance Concerns
- Sidenotes that appear within the basic text
- Other topics
-
The Leanpub 45-day 100% Happiness Guarantee
Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...