Practical Data Processing Using Map, Reduce and Select with Ruby
Practical Data Processing Using Map, Reduce and Select with Ruby
About the Book
This program prints out Pascal's triangle.
puts (0...10).reduce([[1]]) { |a,x|
a.unshift a.first.reduce([0,[]]) { |b,y|
[y,b.last << (b.first + y)]
}.last + [1]
}.reduce([]) { |c,z|
next [z[z.length/2].to_s.length*2,z.length,""] if c.empty?
[c[0],c[1], z.map { |j|
j.to_s.center(c[0])
}.join('').center(c[0]*c[1])+"\n#{c.last}"]
}.last
I found it on the internet at kellegous.com. How does such a complex program get encoded in 10 lines of code? Use this book to learn how to use map, reduce, and select with Ruby to solve data processing problems. Use this book along with a computer wth Ruby installed, a text editor, and the irb (interactive Ruby) prompt. As you read, type in the code, run the code and ponder the results. Tweak the code to test the code and the results. This book will walk you through problems and solutions which are effective because they use map, reduce, and select. You will gain a deeper understanding on how to break data processing problems into processing stages, each of which is understandable, debuggable, and composable, and how to combine the stages to solve your data processing problem.
Table of Contents
-
- My Motivation
-
Audience
- Who This Book Can Help
- Who This Book Might Not Help
- Pre-requisites
-
Part 0 - Basic Ruby
- The command line
- Object Scope
- String
-
Array
- Special Methods
- Hash
- Block passing syntax
- Reading From Files
-
Part 1 Function Overview And Simple Examples
- Map
- Reduce
-
Simple reduce examples
- uniq
- reverse
- max
- Select
-
Part 2 Complex Solutions
-
Debugging Blocks for Map, Reduce and Select
- Debugging map blocks
- Debugging reduce blocks
- Debugging select blocks
- Fizzbuzz
- Sum of Odd Cubes
- Sort a list of names by surname
- Convert a list of names to CSV
- Generate a random list of names
- Clean A Data Set
- Annotate a sequence of sales with running total
- Pascal’s Triangle
- Reverse Polish Notation Parser
- Generate a list of team namebars
- Find Intersection Points of Two Functions
- Group by area code
- Sliding Window Average
- Denormalize a data set
- Pythagorean Triplets
-
Debugging Blocks for Map, Reduce and Select
-
Part 3 - Reverse Engineering Complex Solutions
- Solution For Pascal’s Triangle
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 $14 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