Functional Programming in Ruby
Functional Programming in Ruby
Coding with Style
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 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them