Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (2 votes)
26 views

Learning Functional Data Structures and Algorithms Learn functional data structures and algorithms for your applications and bring their benefits to your work now 1st Edition Atul S. Khot pdf download

The document is about the book 'Learning Functional Data Structures and Algorithms' by Atul S. Khot, which aims to teach functional data structures and algorithms for practical application. It includes various chapters covering topics like lists, binary trees, graph algorithms, and more, emphasizing the benefits of functional programming. Additionally, it provides links to other related books and resources for further learning.

Uploaded by

daskogodetwu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
26 views

Learning Functional Data Structures and Algorithms Learn functional data structures and algorithms for your applications and bring their benefits to your work now 1st Edition Atul S. Khot pdf download

The document is about the book 'Learning Functional Data Structures and Algorithms' by Atul S. Khot, which aims to teach functional data structures and algorithms for practical application. It includes various chapters covering topics like lists, binary trees, graph algorithms, and more, emphasizing the benefits of functional programming. Additionally, it provides links to other related books and resources for further learning.

Uploaded by

daskogodetwu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

Learning Functional Data Structures and

Algorithms Learn functional data structures and


algorithms for your applications and bring their
benefits to your work now 1st Edition Atul S.
Khot download
https://textbookfull.com/product/learning-functional-data-
structures-and-algorithms-learn-functional-data-structures-and-
algorithms-for-your-applications-and-bring-their-benefits-to-
your-work-now-1st-edition-atul-s-khot/

Download more ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Learning functional data structures and algorithms


learn functional data structures and algorithms for
your applications and bring their benefits to your work
now Khot
https://textbookfull.com/product/learning-functional-data-
structures-and-algorithms-learn-functional-data-structures-and-
algorithms-for-your-applications-and-bring-their-benefits-to-
your-work-now-khot/

Probabilistic data structures and algorithms for big


data applications Gakhov

https://textbookfull.com/product/probabilistic-data-structures-
and-algorithms-for-big-data-applications-gakhov/

Data Structures and Algorithms in Swift Kevin Lau

https://textbookfull.com/product/data-structures-and-algorithms-
in-swift-kevin-lau/

Data Structures & Algorithms in Python John Canning

https://textbookfull.com/product/data-structures-algorithms-in-
python-john-canning/
A Common Sense Guide to Data Structures and Algorithms
1st Edition Jay Wengrow

https://textbookfull.com/product/a-common-sense-guide-to-data-
structures-and-algorithms-1st-edition-jay-wengrow/

Data Structures Algorithms in Kotlin Implementing


Practical Data Structures in Kotlin 1st Edition
Raywenderlich Tutorial Team

https://textbookfull.com/product/data-structures-algorithms-in-
kotlin-implementing-practical-data-structures-in-kotlin-1st-
edition-raywenderlich-tutorial-team/

Data Structures Algorithms in Go 1st Edition Hemant


Jain

https://textbookfull.com/product/data-structures-algorithms-in-
go-1st-edition-hemant-jain/

Codeless Data Structures and Algorithms: Learn DSA


Without Writing a Single Line of Code Armstrong Subero

https://textbookfull.com/product/codeless-data-structures-and-
algorithms-learn-dsa-without-writing-a-single-line-of-code-
armstrong-subero/

Algorithms and Data Structures in Action MEAP V12


Marcello La Rocca

https://textbookfull.com/product/algorithms-and-data-structures-
in-action-meap-v12-marcello-la-rocca/
Learning Functional Data
Structures and Algorithms

Learn functional data structures and algorithms for


your applications and bring their benefits to your work
now

Atul S. Khot
Raju Kumar Mishra

BIRMINGHAM - MUMBAI
Learning Functional Data Structures and
Algorithms
Copyright © 2017 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means, without the prior written permission of the
publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without
warranty, either express or implied. Neither the authors, nor Packt Publishing, and its
dealers and distributors will be held liable for any damages caused or alleged to be caused
directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.

First published: February 2017

Production reference: 1170217

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78588-873-1
www.packtpub.com
Credits

Authors Copy Editor


Atul S. Khot Gladson Monteiro
Raju Kumar Mishra

Reviewer Project Coordinator


Muhammad Ali Ejaz Sheejal Shah

Commissioning Editor Proofreader


Kunal Parikh Safis Editing

Acquisition Editor Indexer


Denim Pinto Mariammal Chettiyar

Content Development Editor Graphics


Nikhil Borkar Abhinash Sahu

Technical Editor Production Coordinator


Hussain Kanchwala Shantanu Zagade
About the Authors
Atul S. Khot grew up in Marathwada, a region of the state of Maharashtra, India. A self-
taught programmer, he started writing software in C and C++. A Linux aficionado and a
command-line guy at heart, Atul has always been a polyglot programmer. Having
extensively programmed in Java and dabbled in multiple languages, these days, he is
increasingly getting hooked on Scala, Clojure, and Erlang. Atul is a frequent speaker at
software conferences, and a past Dr. Dobb's product award judge. In his spare time, he
loves to read classic British detective fiction. He is a foodie at heart and a pretty good cook.
Atul someday dreams of working as a master chef, serving people with lip-smacking
dishes.

He was the author of Scala Functional Programming Patterns published by Packt Publishing
in December 2015. The book looks at traditional object-oriented design patterns and shows
how we could use Scala's functional features instead.

I would like to thank my mother, late Sushila S. Khot, for teaching me the value of sharing.
Aai, I remember all you did for the needy girl students! Your support for the blind school -
you brought hope to so many lives! You are no more, however your kindness and selfless
spirit lives on! I know you are watching dear mother, and I will carry on the flame till I
live! I also would like to thank my father, late Shriniwas V. Khot. Anna, I have a photo of
the 'Tamra pat'--an engraved copper plaque--commemorating your great contribution to
the country's freedom struggle. You never compromised on core values --always stood for
the needy and poor. You live on in my memories--a hero forever! I would also want to
thank Martin Odersky for giving us the Scala programming language. I am deeply
thankful to Rich Hickey and the Clojure community for their work on persistent data
structures. Chris Okasaki’s "Purely Functional Data Structures" is a perennial source of
inspiration and insight. I wish to thank Chris for writing the book. This book is influenced
by many ideas Chris presented in his book. I also wish to thank the functional
programming community for all the technical writings which is a source of continual
learning and inspiration. I would love to express my heartfelt thanks to Nikhil Borkar for
all the support through out the book writing. I also would take this opportunity to thank
Hussain Kanchwala for the detailed editing efforts to make the book perfect. You guys are
awesome! Thanks to y’all!
Raju Kumar Mishra is a consultant and corporate trainer for big data and programming.
After completing his B.Tech from Indian Institute of Technology (ISM) Dhanbad, he worked
for Tata Steel. His deep passion for mathematics, data science, and programming took him
to Indian Institute of Science (IISc). After graduating from IISc in computational science, he
worked for Oracle as a performance engineer and software developer. He is an Oracle-
certified associate for Java 7. He is a Hortonworks-certified Apache Hadoop Java
developer, and holds a Developer Certification for Apache Spark (O'Reilly School of
Technology and Databriks), and Revolution R Enterprise-certified Specialist Certifications.
Apart from this, he has also cleared Financial Risk Manager (FRM I) exam. His interest in
mathematics helped him in clearing the CT3 (Actuarial Science) exam.

My heartiest thanks to the Almighty. I would like to thank my mom, Smt. Savitri Mishra,
my sisters, Mitan and Priya, and my maternal uncle, Shyam Bihari Pandey, for their
support and encouragement. I am grateful to Anurag Pal Sehgal, Saurabh Gupta, and all
my friends. Last but not least, thanks to Nikhil Borkar, Content Development Editor at
Packt Publishing for his support in writing this book.
About the Reviewer
Muhammad Ali Ejaz is currently pursuing his graduate degree at Stony Brook University.
His experience, leading up to this academic achievement, ranges from working as a
developer to cofounding a start-up, from serving in outreach organizations to giving talks
at various prestigious conferences. While working as a developer at ThoughtWorks, Ali
cofounded a career empowerment based start-up by providing photographers a platform to
showcase their art and be discovered by potential employers. His passion for computer
science is reflected in his contributions to open source projects, such as GoCD, and his role
in serving as the cofounder and Community Outreach Director of a non-profit organization,
"Women Who Code - Bangalore Chapter". Along with this, he has also been given the
opportunity to speak at different conferences on Continuous Integration and Delivery
practices.

When he is not coding, he enjoys traveling, reading, and tasting new cuisine. You can
follow him on Twitter at @mdaliejaz.

I want to thank my Mom and Dad, who have always been my inspiration. I’d also like to
thank Ahmad and Sana, my siblings, who have been a constant source of cheerful support.
A lot of what I am today is because of them.
www.PacktPub.com
For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF and
ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a
print book customer, you are entitled to a discount on the eBook copy. Get in touch with us
at service@packtpub.com for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a
range of free newsletters and receive exclusive discounts and offers on Packt books and
eBooks.

https://www.packtpub.com/mapt

Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt
books and video courses, as well as industry-leading tools to help you plan your personal
development and advance your career.

Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Customer Feedback
Thank you for purchasing this Packt book. We take our commitment to improving our
content and products to meet your needs seriously—that's why your feedback is so
valuable. Whatever your feelings about your purchase, please consider leaving a review on
this book's Amazon page. Not only will this help us, more importantly it will also help
others in the community to make an informed decision about the resources that they invest
in to learn. You can also review for us on a regular basis by joining our reviewers' club. If
you're interested in joining, or would like to learn more about the benefits we offer,
please contact us: customerreviews@packtpub.com.
Table of Contents
Preface 1
Chapter 1: Why Functional Programming? 8
The imperative way 9
Higher level of abstraction 10
Functional programming is declarative 13
No boilerplate 14
Higher order functions 16
Eschewing null checks 17
Controlling state changes 19
Recursion aids immutability 21
Copy-on-write 23
Laziness and deferred execution 24
Composing functions 26
Summary 29
Chapter 2: Building Blocks 30
The Big O notation 30
Space/time trade-off 33
A word frequency counter 34
Matching string subsets 36
Referential transparency 40
Vectors versus lists 42
Updating an element 46
Not enough nodes 47
Complexities and collections 48
The sliding window 48
Maps 49
Persistent stacks 51
Persistent FIFO queues 52
Sets 53
Sorted set 54
Summary 55
Chapter 3: Lists 56
First steps 57
List head and tail 61
Drop elements 64
Concatenating lists 66
Persistent data structures 69
Tail call optimization 70
List append 72
List prepend 74
Getting value at index 76
Modifying a list value 78
Summary 80
Chapter 4: Binary Trees 81
Node definitions 82
Building the tree 84
Size and depth 86
Complete binary trees 88
Comparing trees 89
Flipping a binary tree 91
Binary tree traversal 93
The accumulator idiom 95
Binary Search Trees 98
Node insertion 99
Searching a key 101
Updating a value 101
Exercising it 102
Summary 103
Chapter 5: More List Algorithms 104
Binary numbers 104
Addition 107
Multiplication 110
Greedy algorithms and backtracking 113
An example of a greedy algorithm 115
The backtracking jig 116
Summary 119
Chapter 6: Graph Algorithms 120
Reversing a list 121
Graph algorithms 123
Graph traversal 124
Avoiding list appending 128

[ ii ]
Topological sorting 129
Cycle detection 132
Printing the cycle 133
Summary 134
Chapter 7: Random Access Lists 136
Incrementing a binary number 137
Adding two binary numbers 139
List of tree roots 140
Insertion 142
Lookup 145
Removal, head, and tail 148
Update 151
Summary 152
Chapter 8: Queues 154
Understanding FIFO queues 155
Functional FIFO queues 156
Invariants 158
Implementing a priority queue 159
Understanding priority queues/heaps 161
Leftist trees 164
Functional heaps 166
Summary 173
Chapter 9: Streams, Laziness, and Algorithms 175
Program evaluation 176
Eager evaluation 176
Argument evaluation 178
Lazy evaluation 179
Lazy evaluation in Scala 180
Lazy evaluation in Clojure 182
Memoization – remembering past results 186
Memoization in Scala 188
Memoization in Clojure 190
Memoizing simpleFactFun 191
Streams 192
Stream in Scala 192
Indexing the elements of a stream 193
Creation of an infinite length stream 193
Stream is immutable 195
Creating a stream from another 196

[ iii ]
Stream to list 197
Appending one stream to another 198
Length of a stream 198
Some mathematical functions of the stream class 198
Some more methods of the stream class 199
Streams (lazy sequence) in Clojure 199
Creating a memoized function of lazy sequences in Clojure 200
Some algorithms on stream 200
Arithmetic progression 201
Arithmetic progression in Scala 202
Arithmetic progression in Clojure 202
Standard Brownian motion 203
Standard Brownian motion in Scala 203
Standard Brownian motion in Clojure 204
Fibonacci series 205
First form of Fibonacci series 205
Second form of Fibonacci series 205
Fibonacci series in Scala 206
Fibonacci series in Clojure 207
Summary 208
Chapter 10: Being Lazy - Queues and Deques 209
Imperative implementations 211
Amortization 212
Problem with queues 213
Strict versus lazy 214
Streams 215
Streams meet queues 217
A sense of balance 220
Amortized deques 221
Summary 225
Chapter 11: Red-Black Trees 227
Terminology 228
Almost balanced trees 229
The concept of rotation 229
Red-Black trees 231
Inserting a node 234
The Black-Red-Red path 237
Left, left – red child and grand child 238
Left child, right grand child 240
Right child, right grand child 241

[ iv ]
Right, left 242
Verifying the transformation 244
Complexity 245
Summary 246
Chapter 12: Binomial Heaps 247
Binomial trees 249
Left child, right sibling 252
A binomial heap 253
Linking up 254
Inserting a value 256
Binary number equivalence 259
Merging 260
Find the minimum 261
Deleting the minimum 262
Exercising the code 263
Complexity 264
Summary 265
Chapter 13: Sorting 266
Stable and unstable sorting 267
Stable sorting 268
Unstable sorting 268
Bubble sort 269
Scala implementation of bubble sort 272
Complexity of bubble sort 274
Selection sort 274
Complexity of selection sort 278
Insertion sort 278
Complexity of insertion sort 282
Merge sort 282
Splitting the sequence 283
Merging two sorted subsequences 285
Complexity of merge sort 289
Quick sort 289
Partition 290
Complexity of quick sort 293
Summary 293
Index 294

[v]
Preface
This book is about functional algorithms and data structures. Algorithms and data
structures are fundamentals of computer programming.

I started my career writing C and C++ code. I always enjoyed designing efficient algorithms.
I have experienced many an Aha! moments, when I saw how powerful and creative pointer
twiddling could be!

For example, reversing a singly linked list using three node pointers is a well known
algorithm. We scan the list once and reverse it by changing the pointer fields of each node.
The three pointer variables guide the reversal process.

I have come across many such pointer tricks and have used them as needed.

I was next initiated into the world of multi-threading! Variables became shared states
between threads! My bagful of tricks was still valid; however, changing state needed a lot of
care, to stay away from insidious threading bugs.

The real world is never picture perfect and someone forgot to synchronize a data structure.

Thankfully we started using C++, which had another bagful of tricks, to control the state
sharing. You could now make objects immutable!

For example, we were able to implement the readers/writer locking pattern effectively.
Immutable objects could be shared without worry among thousands of readers!

We slept easier, the code worked as expected, and all was well with the world!

I soon realized the reason it worked well! Immutability was finally helping us better
understand the state changes!
Preface

The sands of time kept moving and I discovered functional programming.

I could very well see why writing side-effect free code worked! I was hooked and started
playing with Scala, Clojure, and Erlang. Immutability was the norm here.

However, I wondered how the traditional algorithms would look like in a functional
setting--and started learning about it.

A data structure is never mutated in place. Instead, a new version of the data structure is
created. The strategy of copy on write with maximized sharing was an intriguing one! All
that careful synchronization is simply not needed!

The languages come equipped with garbage collection. So, if a version is not needed
anymore, the runtime would take care of reclaiming the memory.

All in good time though! Reading this book will help you see that we need not sacrifice
algorithmic performance while avoiding in-place mutation!

What this book covers


Chapter 1, Why Functional Programming?, takes you on a whirlwind tour of the functional
programming (FP) paradigm. We try to highlight the many advantages FP brings to the
table when compared with the imperative programming paradigm. We discuss FP’s higher
level of abstraction, being declarative, and reduced boilerplate. We talk about the problem
of reasoning about the state change. We see how being immutable helps realize "an easier to
reason about system".

Chapter 2, Building Blocks, provides a whirlwind tour of basic concepts in algorithms. We


talk about the Big O notation for measuring algorithm efficiency. We discuss the space time
trade-off apparent in many algorithms. We next look at referential transparency, a
functional programming concept. We will also introduce you to the notion of persistent
data structures.

Chapter 3, Lists, looks at how lists are implemented in a functional setting. We discuss the
concept of persistent data structures in depth here, showing how efficient functional
algorithms try to minimize copying and maximize structural sharing.

Chapter 4, Binary Trees, discusses binary trees. We look at the traditional binary tree
algorithms, and then look at Binary Search Trees.

[2]
Preface

Chapter 5, More List Algorithms, shows how the prepend operation of lists is at the heart of
many algorithms. Using lists to represent binary numbers helps us see what lists are good
at. We also look at greedy and backtracking algorithms, with lists at the heart.

Chapter 6, Graph Algorithms, looks at some common graph algorithms. We look at graph
traversal and topological sorting, an important algorithm for ordering dependencies.

Chapter 7, Random Access Lists, looks at how we could exploit Binary Search Trees to access
a random list element faster.

Chapter 8, Queues, looks at First In First Out (FIFO) queues. This is another fundamental
data structure. We look at some innovative uses of lists to implement queues.

Chapter 9, Streams, Laziness, and Algorithms, looks at lazy evaluation, another FP feature.
This is an important building block for upcoming algorithms, so we refresh ourselves with
some deferred evaluation concepts.

Chapter 10, Being Lazy – Queues and Deques, looks at double-ended queues, which allow
insertion and deletion at both ends. We first look at the concept of amortization. We use
lazy lists to improve the queue implementation presented earlier, in amortized constant
time. We implement deques also using similar techniques.

Chapter 11, Red-Black Trees, shows how balancing helps avoid degenerate Binary Search
Trees. This is a comparatively complex data structure, so we discuss each algorithm in
detail.

Chapter 12, Binomial Heaps, covers heap implementation offering very efficient merge
operation. We implement this data structure in a functional setting.

Chapter 13, Sorting, talks about typical functional sorting algorithms.

What you need for this book


You need to install Scala and Clojure. All the examples were tested with Scala version
2.11.7. The Clojure examples were tested with Clojure version 1.6.0. You don’t need any
IDE as most of the examples are small enough, so you can key them in the REPL
(Read/Eval/Print Loop).

You also need a text editor. Use whichever you are comfortable with.

[3]
Preface

Who this book is for


The book assumes some familiarity with basic data structures. You should have played
with fundamental data structures like linked lists, heaps, and binary trees. It also assumes
that you have written some code in a functional language.

Scala is used as an implementation language. We do highlight related Clojure features too.


The idea is to illustrate the basic design principles.

We explain the language concepts as needed. However, we just explain the basics and give
helpful pointers, so you can learn more by reading the reference links.

We try to site links that offer hands-on code snippets, so you can practice them yourself.

Walking through an algorithm and discussing the implementation line by line is an


effective aid to understanding.

A lot of thought has gone into making helpful diagrams. Quizzes and exercises are
included, so you can apply what you've learned.

All the code is available online. We strongly advocate keying in the code snippets though,
to internalize the principles and techniques.

Welcome to the wonderland of functional data structures and algorithms!

Conventions
In this book, you will find a number of text styles that distinguish between different kinds
of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The
following function f has a side effect, though."

A block of code is set as follows:


user=> (def v [7 11 19 52 42 72])
#'user/v
user=> (def v1 (conj v 52))
#'user/v1

[4]
Preface

If there is a line (or lines) of code that needs to be highlighted, it is set as follows:
scala> def pop(queue: Fifo): (Int, Fifo) = {
| queue.out match {
| case Nil => throw new IllegalArgumentException("Empty queue");
| case x :: Nil => (x, queue.copy(out = queue.in.reverse, Nil))
| case y :: ys => (y, queue.copy(out = ys))
| }
| }
pop: (queue: Fifo)(Int, Fifo)

New terms and important words are shown in bold. Words that you see on the screen, for
example, in menus or dialog boxes, appear in the text like this: "Clicking the Next button
moves you to the next screen."

Warnings or important notes appear in a box like this.

Tips and tricks appear like this.

Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this
book—what you liked or disliked. Reader feedback is important for us as it helps us
develop titles that you will really get the most out of.

To send us general feedback, simply e-mail feedback@packtpub.com, and mention the


book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or
contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you
to get the most from your purchase.

[5]
Preface

Downloading the example code


You can download the example code files for this book from your account at http://www.p
acktpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.c
om/supportand register to have the files e-mailed directly to you.

You can download the code files by following these steps:

1. Log in or register to our website using your e-mail address and password.
2. Hover the mouse pointer on the SUPPORT tab at the top.
3. Click on Code Downloads & Errata.
4. Enter the name of the book in the Search box.
5. Select the book for which you're looking to download the code files.
6. Choose from the drop-down menu where you purchased this book from.
7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the
latest version of:

WinRAR / 7-Zip for Windows


Zipeg / iZip / UnRarX for Mac
7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPubl
ishing/Learning-Functional-Data-Structures-and-Algorithms. We also have other
code bundles from our rich catalog of books and videos available at https://github.com/P
acktPublishing/. Check them out!

Downloading the color images of this book


We also provide you with a PDF file that has color images of the screenshots/diagrams used
in this book. The color images will help you better understand the changes in the output.
You can download this file from https://www.packtpub.com/sites/default/files/down
loads/LearningFunctionDataStructuresandAlgorithms_ColorImages.pdf.

[6]
Preface

Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do
happen. If you find a mistake in one of our books—maybe a mistake in the text or the
code—we would be grateful if you could report this to us. By doing so, you can save other
readers from frustration and help us improve subsequent versions of this book. If you find
any errata, please report them by visiting http://www.packtpub.com/submit-errata,
selecting your book, clicking on the Errata Submission Form link, and entering the details
of your errata. Once your errata are verified, your submission will be accepted and the
errata will be uploaded to our website or added to any list of existing errata under the
Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/conten


t/supportand enter the name of the book in the search field. The required information will
appear under the Errata section.

Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At
Packt, we take the protection of our copyright and licenses very seriously. If you come
across any illegal copies of our works in any form on the Internet, please provide us with
the location address or website name immediately so that we can pursue a remedy.

Please contact us at copyright@packtpub.com with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable
content.

Questions
If you have a problem with any aspect of this book, you can contact us at
questions@packtpub.com, and we will do our best to address the problem.

[7]
Why Functional Programming?
1
What is functional programming (FP)? Why is it talked about so much?

A programming paradigm is a style of programming. FP is a programming paradigm


characterized by the absence of side effects.

In FP, functions are the primary means of structuring code. The FP paradigm advocates
using pure functions and stresses on immutable data structures. So we don't mutate variables,
but pass a state to function parameters. Functional languages give us lazy evaluation and
use recursion instead of explicit loops. Functions are first-class citizens like numbers or
strings. We pass functions as argument values, just like a numeric or string argument. This
ability to pass functions as arguments allows us to compose behavior, that is, cobble
together something entirely new from existing functions.

In this chapter, we will take a whirlwind tour of functional programming. We will look at
bits of code and images to understand the concepts. This will also lay a nice foundation for
the rest of the book. We will use the functional paradigm and see how it changes the way
we think about data structures and algorithms.

This chapter starts with a look at the concept of abstraction. We will see why abstractions
are important in programming. FP is a declarative style of programming, similar to
Structured Query Language (SQL). Because it is declarative, we use it to tell what we want
the computer to do, rather how it should do it. We will also see how this style helps us stay
away from writing common, repetitive boilerplate code.
Why Functional Programming?

Passing functions as arguments to other, higher order functions is the central idea in FP; we
look at this next. We will also see how to stay away from null checks. Controlled state
change allows us to better reason our code. Being immutable is the key for creating code
that would be easier to reason about.

Next, we will see how recursion helps us realize looping without mutating any variables.
We will wrap up the chapter with a look at lazy evaluation, copy-on-write, and functional
composition.

The imperative way


We keep contrasting FP with the imperative style of programming. What do we mean by
imperative style, though?

The imperative programming style is embodied by a sequence of commands modifying a


program's state. A simple example of this is a for loop. Consider the following pseudo code
snippet to print all the elements of an array:
x = [1,2,3,4...] // an array, x.size tells the number of array elements
for( int i = 0; i < x.size; ++i ) {
println(x[i])
}

Here is a pictorial rendering of the concepts:

[9]
Why Functional Programming?

As the figure shows, the for loop establishes an initial state by setting the variable i to 0.
The variable is incremented every time the loop is repeated; this is what we mean by the
state being modified. We keep reading and modifying the state, that is, the loop variable,
until there are no elements left in the array.

FP advocates staying away from any state modification. It gives us tools so we don't worry
about how to loop over a collection; instead, we focus on what we need to do with each
element of the collection.

Higher level of abstraction


FP allows us to work at a higher level of abstraction. Abstraction is selective ignorance. The
world we know of runs on abstractions. If we say, “Give me sweet condensed milk frozen
with embedded dry fruits' someone might really have a hard time understanding it.
Instead, just say “ice-cream”! Aha! It just falls into place and everyone is happy.

Abstractions are everywhere. An airplane is an abstraction, so is a sewing machine or a


train. When we wish to travel by train, we buy a ticket, board the train, and get off at the
destination. We really don't worry about how the train functions. We simply can't be
expected to deal with all the intricacies of a train engine. As long as it serves our purpose,
we ignore details related to how an engine really works.

What are the benefits of an abstraction? We don't get bogged down into unnecessary
details. Instead, we focus on the task at hand by applying higher level programming
abstractions.

Compare the preceding for loop with the functional code snippet:
scala> val x = Array(1,2,3,4,5,6)
x: Array[Int] = Array(1, 2, 3, 4, 5, 6)
scala> x.foreach(println _)
1
2
...

We simply focus on the task at hand (print each element of an array) and don't care about
the mechanics of a for loop. The functional version is more abstract.

[ 10 ]
Why Functional Programming?

As software engineers, when we implement an algorithm and run it, we are intentionally
ignoring many details.

We know that the preceding sandwich stack somehow works and faithfully translates the
algorithm into runnable code.

Applying higher level abstractions is commonly done in functional languages. For example,
consider the following Clojure REPL snippet:
user=> ((juxt (comp str *) (comp str +)) 1 2 3 4 5)
["120" "15"]

[ 11 ]
Why Functional Programming?

We are juxtaposing two functions; each of these are in turn composed of the str function
and an arithmetic function:

We just don't worry about how it works internally. We just use high-level abstractions
cobbled together with existing pieces of abstract functionality.

We will be looking at abstract data types (ADT) closely in this book. For example, when we
talk about a stack, we think of the Last In First Out (LIFO) order of access. However, this
ADT is realized by implementing the stack via a data structure, such as a linked list or an
array.

[ 12 ]
Why Functional Programming?

Here is a figure showing the First In First Out (FIFO) ADT in action. The FIFO queue is the
normal queue we encounter in life, for example, queuing up at a booking counter. The
earlier you get into a queue, the sooner you get serviced.

The FIFO queue is an ADT. True that we think of it as an ADT; however, as shown in the
preceding diagram, we can also implement the queue backed by either an array or a linked
list.

Functional programming is declarative


When we use SQL, we just express our intent. For example, consider this:
mysql> select count(*) from book where author like '%wodehouse%';

We just say what we are looking for. The actual mechanism that gets the answer is hidden
from us. The following is a little too simplistic but suitable example to prove the point.

[ 13 ]
Why Functional Programming?

The SQL engine will have to loop over the table and check whether the author column
contains the wodehouse string. We really don't need to worry about the search algorithm.
The author table resides on a disk somewhere. The number of table rows that need to be
filtered could easily exceed the available memory. The engine handles all such complexities
for us though.

We just declare our intent. The following Scala snippet is declarative. It counts the number of
even elements in the input list:
scala> val list = List(1, 2, 3, 4, 5, 6)
list: List[Int] = List(1, 2, 3, 4, 5, 6)

scala> list.count( _ % 2 == 0 )
res0: Int = 3

The code uses a higher order function, namely count. This takes another function, a
predicate, as an argument. The line loops over each list element, invokes the argument
predicate function, and returns the count.

Here is another example of Clojure code that shows how to generate a combination of
values from two lists:
user=> (defn fun1 [list1 list2]
#_=> (for [x list1 y list2]
#_=> (list x y)))
#'user/fun1
user=> (fun1 '(1 2 3) '(4 5 6))
((1 4) (1 5) (1 6) (2 4) (2 5) (2 6) (3 4) (3 5) (3 6))

Note the code used to generate the combination. We use for comprehension to just state what
we need done and it would be done for us.

No boilerplate
Boilerplate code consists sections of the same code written again and again. For example,
writing loops is boilerplate, as is writing getters and setters for private class members.

[ 14 ]
Why Functional Programming?

As the preceding code shows, the loop is implicit:


scala> List(1, 2, 3, 4, 5) partition(_ % 2 == 0)
res3: (List[Int], List[Int]) = (List(2, 4),List(1, 3, 5))

We just wish to separate the odd and even numbers. So we just specify the criteria via a
function, an anonymous function in this case. This is shown in the following image:

What is boilerplate? It is a for loop, for example. In the imperative world, we code the loop
ourselves. We need to tell the system how to iterate over a data structure.

Isn't Scala code just to the point? We tell what we need and the loop is implied for us. No
need to write a for loop, no need to invent a name for the loop variable, and so on. We just
got rid of the boilerplate.

Here is a Clojure snippet that shows how to multiply each element of a vector by 2:
user=> (map * (repeat 2) [1 2 3 4 5])
(2 4 6 8 10)

The map function hides the loop from us. Then (repeat 2) function call generates an
infinite sequence.

[ 15 ]
Other documents randomly have
different content
northern line in one grand, mad fury of effort that lasted day after
day until the tally man joyously threw away his chewed pencil and
gladly surrendered the last sheet to the foreman. The first half of the
game was over. Gone as if it were a nightmare was the confusion of
noise and dust and cows that hid a remarkable certainty of method.
But as if to prove it not a dream, four thousand cows were held in
three herds on the great range, in charge of the extra men.
Buck, leading the regular outfit from the north line and toward
the bunkhouse, added the figures of the last tally sheet to the totals
he had in a little book, and smiled with content. Behind him, cheerful
as fools, their bodies racking with weariness, their faces drawn and
gaunt, knowing that their labors were not half over, rode the outfit,
exchanging chaff and banter in an effort to fool themselves into the
delusion that they were fresh and "chipper." Nearing the bunkhouse
they cheered lustily as they caught sight of the hectic cook laboring
profanely with two balking pintos that had backed his wagon half
over the edge of a barranca and then refused to pull it back again.
Cookie's reply, though not a cheer, was loud and pregnant with
feeling. To think that he had driven those two animals for the last
two weeks from one end of the ranch to the other without a mishap,
and then have them balance him and his wagon on the crumbling
edge of a twenty-foot drop when not a half mile from the
bunkhouse, thus threatening the loss of the wagon and all it
contained and the mangling of his sacred person! And to make it
worse, here came a crowd of whooping idiots to feast upon his
discomfiture.
The outfit, slowing so as not to frighten the devilish pintos and
start them backing again, drew near; and suddenly the air became
filled with darting ropes, one of which settled affectionately around
Cookie's apoplectic neck. In no time the strangling, furious dough-
king was beyond the menace of the crumbling bank, flat on his back
in the wagon, where he had managed to throw himself to escape
the whistling hoofs that quickly turned the dashboard into
matchwood. When he managed to get the rope from his neck he
arose, unsteady with rage, and choked as he tried to speak before
the grinning and advising outfit. Before he could get command over
his tongue the happy bunch wheeled and sped on its way, shrieking
with mirth unholy. They had saved him from probable death, for
Cookie was too obstinate to have jumped from the wagon; but they
not only forfeited all right to thanks and gratitude, but deserved
horrible deaths for the conversation they had so audibly carried on
while they worked out the cook's problem. And their departing
words and gestures made homicide justifiable and a duty. It was in
this frame of mind that Cookie watched them go.
Buck, emerging from the bunkhouse in time to see the rescue,
leaned against the door and laughed as he had not laughed for one
heart-breaking winter. Drying his eyes on the back of his hand, he
looked at the bouncing, happy crowd tearing southward with an
energy of arms and legs and lungs that seemed a miracle after the
strain of the round-up. Just then a strange voice made him wheel
like a flash, and he saw Billy Williams sitting solemnly on his horse
near the corner of the house.
"Hullo, Williams," Buck grunted, with no welcoming warmth in
his voice. "What th' devil brings you up here?"
"I want a job," replied Billy. The two, while never enemies nor
interested in any mutual disagreements, had never been friends.
They never denied a nodding acquaintance, nor boasted of it. "That
Norther shore raised h—l. There 's ten men for every job, where I
came from."
The foreman, with that quick decision that was his in his earlier
days, replied crisply. "It's your'n. Fifty a month, to start."
"Keno. Lemme chuck my war-bag through that door an' I'm
ready," smiled Billy. He believed he would like this man when he
knew him better. "I thought th' Diamond Bar, over east a hundred
mile, had weathered th' storm lucky. You got 'em beat. They 're
movin' heaven an' earth to get a herd on the trail, but they did n't
have no job for me," he laughed, flushing slightly. "Sam Crawford
owns it," he explained naïvely.
Buck laughed outright. "I reckon you did n't have much show
with Sam, after that li'l trick you worked on him in Fenton. So Sam is
in this country? How are they fixed?"
"They aims to shove three thousan' east right soon. It's fancy
prices for th' first herd that gets to Sandy Creek," he offered. "I
heard they 're havin' lots of wet weather along th' Comanchee;
mebby Sam 'll have trouble a-plenty gettin' his herd acrost. Cows is
plumb aggervatin' when it comes to crossin' rivers," he grinned.
Buck nodded. "See that V openin' on th' sky line?" he asked,
pointing westward. "Ride for it till you see th' herd. Help 'em with it.
We 'll pick it up t'morrow." He turned on his heel and entered the
house, grave with a new worry. He had not known that there was a
ranch where Billy had said the Diamond Bar was located; and a
hundred miles handicap meant much in a race to Sandy Creek.
Crawford was sure to drive as fast as he dared. He was glad that
Billy had mentioned it, and the wet weather along the Comanchee—
Billy already had earned his first month's pay.
All that day and the next the consolidation of the three herds
and the preparation for the drive went on. Sweeping up from the
valley the two thousand three- and four-year-olds met and joined
the thousand that waited between Little Timber and Three Rocks;
and by nightfall the three herds were one by the addition of the
thousand head from Big Coulee. Four thousand head of the best
cattle on the ranch spent the night within gunshot of the bunkhouse
and corrals on Snake Creek.
Buck, returning from the big herd, smiled as he passed the
chuck-wagon and heard Cookie's snores, and went on, growing
serious all too quickly. At the bunkhouse he held a short consultation
with his regular outfit and then returned to the herd again while his
drive crew turned eagerly to their bunks. Breakfast was eaten by
candle light and when the eastern sky faded into a silver gray Skinny
Thompson vaulted into the saddle and loped eastward without a
backward glance. The sounds of his going scarcely had died out
before Hopalong, relieved of the responsibilities of trail boss,
shouldered others as weighty and rode into the north-east with
Lanky at his side. Behind him, under charge of Red, the herd started
on its long and weary journey to Sandy Creek, every man of the
outfit so imbued with the spirit of the race that even with its
hundred miles' advantage the Diamond Bar could not afford to waste
an hour if it hoped to win.
Out of the side of a verdant hill, whispering and purling, flowed
a small stream and shyly sought the crystal depths of a rock-bound
pool before gaining courage enough to flow gently over the smooth
granite lip and scurry down the gentle slope of the arroyo. To one
side of it towered a splinter of rock, slender and gray, washed clean
by the recent rains. To the south of it lay a baffling streak a little
lighter than the surrounding grass lands. It was, perhaps, a quarter
of a mile wide and ended only at the horizon. This faint band was
the Dunton trail, not used enough to show the strong characteristics
of the depressed bands found in other parts of the cow-country. If
followed it would lead one to Dunton's Ford on the Comanchee, forty
miles above West Bend, where the Diamond Bar aimed to cross the
river.
The shadow of the pinnacle drew closer to its base and had
crossed the pool when Skinny Thompson rode slowly up the near
bank of the ravine, his eyes fixed smilingly on the splinter of rock.
He let his mount nuzzle and play with the pool for a moment before
stripping off the saddle and turning the animal loose to graze. Taking
his rifle in the hope of seeing game, he went up to the top of the
hill, glanced westward and then turned and gazed steadily into the
northeast, sweeping slowly over an arc of thirty degrees. He stood
so for several minutes and then grunted with satisfaction and
returned to the pool. He had caught sight of a black dot far away on
the edge of the skyline that split into two parts and showed a
sidewise drift. Evidently his friends would be on time. Of the herd he
had seen no sign, which was what he had expected.
When at last he heard hoofbeats he arose lazily and stretched,
chiding himself for falling asleep, and met his friends as they turned
into sight around the bend of the hill. "Reckoned you might 'a' got
lost," he grinned sleepily.
"G'wan!" snorted Lanky.
"What'd you find?" eagerly demanded Hopalong.
"Three thousan' head on th' West Bend trail five days ahead of
us," replied Skinny. "Ol' Sam is drivin' hard." He paused a moment.
"Acts like he knows we 're after him. Anyhow, I saw that feller that
visited us on th' third day of th' round-up. So I reckon Sam knows."
Lanky grinned. "He won't drive so hard later. I 'd like to see him
when he sees th' Comanchee! Bet it's a lake south of Dunton's
'cordin' to what we found. But it ain't goin' to bother us a whole lot."
Hopalong nodded, dismounted and drew a crude map in the
sand of the trail. Skinny watched it, grave and thoughtful until, all at
once, he understood. His sudden burst of laughter startled his
companions and they exchanged foolish grins. It appeared that from
Dunton's Ford north, in a distance of forty miles, the Comanchee
was practically born. So many feeders, none of them formidable,
poured into it that in that distance it attained the dignity of a river.
Hopalong's plan was to drive off at a tangent running a little north
from the regular trail and thus cross numerous small streams in
preference to going on straight and facing the swollen Comanchee at
Dunton's Ford. As the regular trail turned northward when not far
from Sandy Creek they were not losing time. Laughing gaily they
mounted and started west for the herd which toiled toward them
many miles away. Thanks to the forethought that had prompted
their scouting expedition the new trail was picked out in advance
and there would be no indecision on the drive.
Eighty miles to the south lay the fresh trail of the Diamond Bar
herd, and five days' drive eastward on it, facing the water-covered
lowlands at West Bend, Sam Crawford held his herd, certain that the
river would fall rapidly in the next two days. It was the regular ford,
and the best on the river. The water did fall, just enough to lure him
to stay; but, having given orders at dark on the second night for an
attempt at crossing at daylight the next morning, he was amazed
when dawn showed him the river was back to its first level.
Sam was American born, but affected things English and
delighted in spelling "labor" and like words with a "u." He hated hair
chaps and maintained that the gun-play of the West was mythical
and existed only in the minds of effete Easterners. Knowing that, it
was startling to hear him tell of Plummer, Hickock, Roberts,
Thompson and a host of other gunmen who had splotched the West
with blood. Not only did every man of that section pack a gun, but
Crawford, himself, packed one, thus proving himself either a
malicious liar or an imbecile. He acted as though the West belonged
to him and that he was the arbiter of its destiny and its chosen
historian—which made him troublesome on the great, free ranges.
Only that his pretensions and his crabbed, irascible, childish temper
made him ludicrous he might have been taken seriously, to his
sorrow. Failing miserably at law, he fled from such a precarious
livelihood, beset with a haunting fear that he had lost his grip, to an
inherited ranch. This fear that pursued him turned him into a carping
critic of those who excelled him in most things, except in fits of lying
about the West as it existed at that time.
When he found that the river was over the lowlands again he
became furious and, carried away by rage, shouted down the wiser
counsel of his clear-headed night boss and ordered the herd into the
water. Here and there desperate, wild-eyed steers wheeled and
dashed back through the cordon of riders, their numbers constantly
growing as the panic spread. The cattle in the front ranks, forced
into the swirling stream by the pressure from the rear, swam with
the current and clambered out below, adding to the confusion.
Steers fought throughout the press and suddenly, out of the right
wing of the herd, a dozen crazed animals dashed out in a bunch for
the safety of the higher ground; and after them came the herd, an
irresistible avalanche of maddened beef. It was not before dark that
they were rounded up into a nervous, panicky herd once more. The
next morning they were started north along the river, to try again at
Dunton's Ford, which they reached in three days, and where another
attempt at crossing the river proved in vain.
Meanwhile the Bar-20 herd pushed on steadily with no
confusion. It crossed the West Run one noon and the upper waters
of the Little Comanchee just before dark on the same day. Next
came East Run, Pawnee Creek and Ten Mile Creek, none of them
larger than the stream the cattle were accustomed to back on the
ranch. Another day's drive brought them to the west branch of the
Comanchee itself, the largest of all the rivers they would meet. Here
they were handled cautiously and "nudged" across with such care
that a day was spent in the work. The following afternoon the east
branch held them up until the next day and then, with a clear trail,
they were sent along on the last part of the long journey.
When Sam Crawford, forced to keep on driving north along the
Little Comanchee, saw that wide, fresh trail, he barely escaped
apoplexy and added the finishing touches to the sullenness of his
outfit. Seeing the herd across, he gave orders for top speed and
drove as he never had driven before; and when the last river had
been left behind he put the night boss in charge of the cattle and
rode on ahead to locate his rivals of the drive. Three days later,
when he returned to his herd, he was in a towering fury and talked
constantly of his rights and an appeal to law, and so nagged his men
that mutiny stalked in his shadow.
When the Bar-20 herd was passing to the south of the little
village of Depau, Hopalong turned back along the trail to find the
Diamond Bar herd. So hard had Sam pushed on that he was only
two days' drive behind Red and his outfit when Hopalong rode
smilingly into the Diamond Bar camp. He was talking pleasantly of
shop to some of the Diamond Bar punchers when Sam dashed up
and began upbraiding him and threatening dire punishment.
Hopalong, maintaining a grave countenance, took the lacing meekly
and humbly as he winked at the grinning punchers. Finally, after
exasperating Sam to a point but one degree removed from
explosion, he bowed cynically, said "so-long" to the friendly outfit
and loped away toward his friends. Sam, choking with rage, berated
his punchers for not having thrown out the insulting visitor and
commanded more speed, which was impossible. Reporting to Red
the proximity of their rivals, Hopalong fell in line and helped drive
the herd a little faster. The cattle were in such condition from the
easy traveling of the last week that they could easily stand the pace
if Crawford's herd could. So the race went on, Red keeping the same
distance ahead day after day.
Then came the night when Sandy Creek lay but two days' drive
away. A storm had threatened since morning and the first lightning
of the drive was seen. The cattle were mildly restless when
Hopalong rode in at midnight and he was cheerfully optimistic. He
was also very much awake, and after trying in vain to get to sleep
he finally arose and rode back along the trail toward the stragglers,
which Jimmy and Lanky were holding a mile away. Red had pushed
on to the last minute of daylight and Lanky had decided to hold the
stragglers instead of driving them up to the main herd so they would
start even with it the following morning. It was made up of the
cattle that had found the drive too much for them and was smaller
than the outfit had dared to hope for.
Hopalong had just begun to look around for the herd when it
passed him with sudden uproar. Shouting to a horseman who rode
furiously past, he swung around and raced after him, desperately
anxious to get in front of the stampede to try to check it before it
struck the main herd and made the disaster complete. For the next
hour he was in a riot of maddened cattle and shaved death many
times by the breadth of a hand. He could hear Jimmy and Lanky
shouting in the black void, now close and now far away. Then the
turmoil gradually ceased and the remnant of the herd paused,
undecided whether to stop or go on. He flung himself at it and by
driving cleverly managed to start a number of cows to milling, which
soon had the rest following suit. The stampede was over. A cursing
blot emerged from the darkness and hailed. It was Lanky, coldly
ferocious. He had not heard Jimmy for a long time and feared that
the boy might be lying out on the black plain, trampled into a
shapeless mass of flesh. One stumble in front of the charging herd
would have been sufficient.
Daylight disclosed the missing Jimmy hobbling toward the
breakfast fire at the cook wagon. He was bruised and bleeding and
covered with dirt, his clothes ripped and covered with mud; and
every bone and muscle in his body was alive with pain.
The Diamond Bar's second squad had ridden in to breakfast
when a horseman was seen approaching at a leisurely lope. Sam,
cursing hotly, instinctively fumbled at the gun he wore at his thigh in
defiance to his belief concerning the wearing of guns. He blinked
anxiously as the puncher stopped at the wagon and smiled a heavy-
eyed salutation. The night boss emerged from the shelter of the
wagon and grinned a sheepish welcome. "Well, Cassidy, you fellers
got th' trail somehow. We was some surprised when we hit yore
trail. How you makin' it?"
"All right, up to last night," replied Hopalong, shaking hands
with the night boss. "Got a match, Barnes?" he asked, holding up an
unlighted cigarette. They talked of things connected with the drive
and Hopalong cautiously swung the conversation around to mishaps,
mentioning several catastrophes of past years. After telling of a
certain stampede he had once seen, he turned to Barnes and asked
a blunt question. "What would you do to anybody as stampeded
yore stragglers within a mile of th' main herd on a stormy night?"
The answer was throaty and rumbling. "Why, shoot him, I reckon."
The others intruded their ideas and Crawford squirmed, his hand
seeking his gun under the pretense of tightening his belt.
Hopalong arose and went to his horse, where a large bundle of
canvas was strapped behind the saddle. He loosened it and unrolled
it on the ground. "Ever see this afore, boys?" he asked, stepping
back. Barnes leaped to his feet with an ejaculation of surprise and
stared at the canvas. "Where'd you git it?" he demanded. "That's our
old wagon cover!"
Hopalong, ignoring Crawford, looked around the little group and
smiled grimly. "Well, last night our stragglers was stampeded. Lanky
told me he saw somethin' gray blow past him in th' darkness, an'
then th' herd started. We managed to turn it from th' trail an' so it
did n't set off our main herd. Jimmy was near killed—well, you know
what it is to ride afore stampeded cows. I found this cover blowed
agin' a li'l clump of trees, an' when I sees yore mark, I reckoned I
ought to bring it back." He dug into his pocket and brought out a
heavy clasp knife. "I just happened to see this not far from where th'
herd started from, so I reckoned I 'd return it, too." He held it out to
Barnes, who took it with an oath and wheeled like a flash to face his
employer.
Crawford was backing toward the wagon, his hand resting on
the butt of his gun, and a whiteness of face told of the fear that
gripped him. "I 'll take my time, right now," growled Barnes. "D—d if
I works another day for a low-lived coyote that 'd do a thing like
that!" The punchers behind him joined in and demanded their
wages. Hopalong, still smiling, waved his hand and spoke. "Don't
leave him with all these cows on his hands, out here on th' range. If
you quits him, wait till you get to Sandy Creek. He ain't no man, he
ain't; he 's a nasty lil brat of a kid that couldn't never grow up into a
man. So, that bein' true, he ain't goin' to get handled like a man. I
'm goin' to lick him, 'stead of shootin' him like he was a man. You
know," he smiled, glancing around the little circle, "us cowpunchers
don't never carry guns. We don't swear, nor wear chaps, even if all
of us has got 'em on right now. We say 'please' an' 'thank you' an'
never get mad. Not never wearin' a gun I can't shoot him; but, by G
—d, I can lick him th' worst he's ever been licked, an' I 'm goin' to
do it right now." He wheeled to start after the still-backing cowman,
and leaped sideways as a cloud of smoke swirled around his hips.
Crawford screamed with fear and pain as his Colt tore loose from his
fingers and dropped near the wheel of the wagon. Terror gripped
him and made him incapable of flight. Who was this man, what was
he, when he could draw and fire with such speed and remarkable
accuracy? Crawford's gun had been half raised before the other had
seen it. And before his legs could perform one of their most
cherished functions the limping cowpuncher was on him, doing his
best to make good his promise. The other half of the Diamond Bar
drive crew, attracted by the commotion at the chuck wagon, rode in
with ready guns, saw their friends making no attempt at
interference, asked a few terse questions and, putting up their guns,
forthwith joined the circle of interested and pleased spectators to
root for the limping redhead.
Crawford's Colt tore loose from his fingers and dropped
near the wagon wheel

* * * * *

Red, back at the Bar-20 wagon, inquired of Cookie the whereabouts


of Hopalong. Cookie, still smarting under Jimmy's galling fire of
language, grunted ignorance and a wish. Red looked at him,
scowling. "You can talk to th' Kid like that, mebby; but you get a civil
tongue in yore head when any of us grown-ups ask questions." He
turned on his heel, looked searchingly around the plain and
mounting, returned to the herd, perplexed and vexed. As he left the
camp, Jimmy hobbled around the wagon and stared after him. "Kid!"
he snorted. "Grown-ups!" he sneered. "Huh!" He turned and
regarded Cookie evilly. "Yo 're gonna get a good lickin' when I get so
I can move better," he promised. Cookie lifted the red flannel dish-
rag out of the pan and regarded it thoughtfully. "You better wait," he
agreed pleasantly. "You can't run now. I 'm honin' for to drape this
mop all over yore wall-eyed face; but I can wait." He sighed and
went back to work. "Wish Red would shove you in with th' rest of th'
cripples back yonder, an' get you off'n my frazzled nerves."
Jimmy shook his head sorrowfully and limped around the wagon
again, where he resumed his sun bath. He dozed off and was
surprised to be called for dinner. As he arose, grunting and growling,
he chanced to look westward, and his shout apprised his friends of
the return of the missing red-head.
Hopalong dismounted at the wagon and grinned cheerfully,
despite the suspicious marks on his face. Giving an account of
events as they occurred at the Diamond Bar chuck wagon, he wound
up with: "Needn't push on so hard, Red. Crawford's herd is due to
stay right where it is an' graze peaceful for a week. I heard Barnes
give th' order before I left. How's things been out here while I was
away?"
Red glared at him, ready to tell his opinion of reckless fools that
went up against a gun-packing crowd alone when his friends had
never been known to refuse to back up one of their outfit. The
words hung on his lips as he waited for a chance to launch them.
But when that chance came he had been disarmed by the
cheerfulness of his happy friend. "Hoppy," he said, trying to be
severe, "yo 're nothing' but a crazy, d—d fool. But what did they say
when you started for huffy Sam like that?"

X
THE HOLD-UP

The herd delivered at Sandy Creek had traveled only half way, for
the remaining part of the journey would be on the railroad. The
work of loading the cars was fast, furious fun to anyone who could
find humor enough in his make-up to regard it so. Then came a
long, wearying ride for the five men picked from the drive outfit to
attend to the cattle on the way to the cattle pens of the city. Their
work at last done, they "saw the sights" and were now returning to
Sandy Creek.
The baggage smoking-car reeked with strong tobacco, the
clouds of smoke shifting with the air currents, and dimly through the
haze could be seen several men. Three of these were playing cards
near the baggage-room door, while two more lounged in a seat half
way down the aisle and on the other side of the car. Across from the
card-players, reading a magazine, was a fat man, and near the
water cooler was a dyspeptic-looking individual who was grumbling
about the country through which he was passing.
The first five, as their wearing apparel proclaimed, were not of
the kind usually found on trains, not the drummer, the tourist, or the
farmer. Their heads were covered with heavy sombreros, their coats
were of thick, black woolens, and their shirts were also of wool.
Around the throat of each was a large handkerchief, knotted at the
back; their trousers were protected by "chaps," of which three were
of goatskin. The boots were tight-fitting, narrow, and with high
heels, and to them were strapped heavy spurs. Around the waist,
hanging loosely from one hip, each wore a wide belt containing fifty
cartridges in the loops, and supporting a huge Colt's revolver, which
rested against the thigh.
They were happy and were trying to sing but, owing to different
tastes, there was noticeable a lack of harmony. "Oh Susanna" never
did go well with "Annie Laurie," and as for "Dixie," it was hopelessly
at odds with the other two. But they were happy, exuberantly so, for
they had enjoyed their relaxation in the city and now were returning
to the station where their horses were waiting to carry them over
the two hundred miles which lay between their ranch and the
nearest railroad-station.
For a change the city had been pleasant, but after they had
spent several days there it lost its charm and would not have been
acceptable to them even as a place in which to die. They had spent
their money, smoked "top-notcher" cigars, seen the "shows" and
feasted each as his fancy dictated, and as behooved cowpunchers
with money in their pockets. Now they were glad that every hour
reduced the time of their stay in the smoky, jolting, rocking train, for
they did not like trains, and this train was particularly bad. So they
passed the hours as best they might and waited impatiently for the
stop at Sandy Creek, where they had left their horses. Their trip to
the "fence country" was now a memory, and they chafed to be again
in the saddle on the open, wind-swept range, where miles were
insignificant and the silence soothing.
The fat man, despairing of reading, watched the card-players
and smiled in good humor as he listened to their conversation, while
the dyspeptic, nervously twisting his newspaper, wished that he
were at his destination. The baggage-room door opened and the
conductor looked down on the card-players and grinned. Skinny
moved over in the seat to make room for the genial conductor.
"Sit down, Simms, an' take a hand," he invited. Laughter arose
continually and the fat man joined in it, leaning forward more closely
to watch the play.
Lanky tossed his cards face down on the board and grinned at
the onlooker.
"Billy shore bluffs more on a varigated flush than any man I
ever saw."
"Call him once in a while and he 'll get cured of it," laughed the
fat man, bracing himself as the train swung around a sharp turn.
"He 's too smart," growled Billy Williams. "He tried that an'
found I did n't have no varigated flushes. Come on, Lanky, if yo 're
playing cards, put up."
Farther down the car, their feet resting easily on the seat in
front of them, Hopalong and Red puffed slowly at their large, black
cigars and spoke infrequently, both idly watching the plain flit by in
wearying sameness, and both tired and lazy from doing nothing but
ride.
"Blast th' cars, anyhow," grunted Hopalong, but he received no
reply, for his companion was too disgusted to say anything.
A startling, sudden increase in the roar of the train and a gust of
hot, sulphurous smoke caused Hopalong to look up at the brakeman,
who came down the swaying aisle as the door slammed shut.
"Phew!" he exclaimed, genially. "Why in thunder don't you
fellows smoke up?"
Hopalong blew a heavy ring, stretched energetically and
grinned: "Much farther to Sandy Creek?"
"Oh, you don't get off for three hours yet," laughed the
brakeman.
"That's shore a long time to ride this bronc train," moodily
complained Red as the singing began again. "She shore pitches a-
plenty," he added.
The train-hand smiled and seated himself on the arm of the
front seat:
"Oh, it might be worse."
"Not this side of hades," replied Red with decision, watching his
friend, who was slapping the cushions to see the dust fly out: "Hey,
let up on that, will you! There's dust a-plenty without no help from
you!"
The brakeman glanced at the card-players and then at
Hopalong.
"Do your friends always sing like that?" he inquired.
"Mostly, but sometimes it's worse."
"On the level?"
"Shore enough; they're singing 'Dixie,' now. It's their best
song."
"That ain't 'Dixie!'"
"Yes it is: that is, most of it."
"Well, then, what's the rest of it?"
"Oh, them's variations of their own," remarked Red, yawning
and stretching. "Just wait till they start something sentimental; you
'll shore weep."
"I hope they stick to the variations. Say, you must be a pretty
nifty gang on the shoot, ain't you?"
"Oh, some," answered Hopalong.
"I wish you fellers had been aboard with us one day about a
month ago. We was the wrong end of a hold-up, and we got cleaned
out proper, too."
"An' how many of 'em did you get?" asked Hopalong quickly,
sitting bolt upright.
The fat man suddenly lost his interest in the card-game and
turned an eager ear to the brakeman, while the dyspeptic stopped
punching holes in his time-card and listened. The card-players
glanced up and then returned to their game, but they, too, were
listening.
The brakeman was surprised: "How many did we get! Gosh! we
didn't get none! They was six to our five."
"How many cards did you draw, you Piute?" asked Lanky.
"None of yore business; I ain't dealing, an' I would n't tell you if
I was," retorted Billy.
"Well, I can ask, can't I?"
"Yes—you can, an' did."
"You didn't get none?" cried Hopalong, doubting his ears.
"I should say not!"
"An' they owned th' whole train?"
"They did."
Red laughed. "Th' cleaning-up must have been sumptuous an'
elevating."
"Every time I holds threes he allus has better," growled Lanky to
Simms.
"On th' level, we couldn't do a thing," the brakeman ran on.
"There 's a water tank a little farther on, and they must 'a' climbed
aboard there when we stopped to connect. When we got into the
gulch the train slowed down and stopped and I started to get up to
go out and see what was the matter; but I saw that when I looked
down a gun-barrel. The man at the throttle end of it told me to put
up my hands, but they were up as high then as I could get 'em
without climbin' on the top of the seat.
"Can't you listen and play at th' same time?" Lanky asked Billy.
"I wasn't countin' on takin' the gun away from him," the
brakeman continued, "for I was too busy watchin' for the slug to
come out of the hole. Pretty soon somebody on the outside whistled
and then another feller come in the car; he was the one that did the
cleanin' up. All this time there had been a lot of shootin' outside, but
now it got worse. Then I heard another whistle and the engine
puffed up the track, and about five minutes later there was a big
explosion, and then our two robbers backed out of the car among
the rocks shootin' back regardless. They busted a lot of windows."
"An' you did n't git none," grumbled Hopalong, regretfully.
"When we got to the express-car, what had been pulled around
the turn," continued the brakeman, not heeding the interruption,
"we found a wreck. And we found the engineer and fireman standin'
over the express-messenger, too scared to know he would n't come
back no more. The car had been blowed up with dynamite, and his
fighting soul went with it. He never knowed he was licked."
"An' nobody tried to help him!" Hopalong exclaimed, wrathfully
now.
"Nobody wanted to die with him," replied the brakeman.
"Well," cried the fat man, suddenly reaching for his valise, "I 'd
like to see anybody try to hold me up!" Saying which he brought
forth a small revolver.
"You 'd be praying out of your bald spot about that time,"
muttered the brakeman.
Hopalong and Red turned, perceived the weapon, and then
exchanged winks.
"That's a fine shootin'-iron, stranger," gravely remarked
Hopalong.
"You bet it is!" purred the owner, proudly. "I paid six dollars for
that gun."
Lanky smothered a laugh and his friend grinned broadly: "I
reckon that'd kill a man—if you stuck it in his ear."
"Pshaw!" snorted the dyspeptic, scornfully. "You wouldn't have
time to get it out of that grip. Think a train-robber is going to let you
unpack? Why don't you carry it in your hip-pocket, where you can
get at it quickly?"
There were smiles at the stranger's belief in the hip-pocket
fallacy but no one commented upon it.
"Was n't there no passengers aboard when you was stuck up?"
Lanky asked the conductor.
"Yes, but you can't count passengers in on a deal like that."
Hopalong looked around aggressively: "We 're passengers, ain't
we?"
"You certainly are."
"Well, if any misguided maverick gets it into his fool head to
stick us up, you see what happens. Don't you know th' fellers
outside have all th' worst o' th' deal?"
"They have not!" cried the brakeman.
"They 've got all the best of it," asserted the conductor
emphatically. "I 've been inside, and I know."
"Best nothing!" cried Hopalong. "They are on th' ground,
watching a danger-line over a hundred yards long, full of windows
and doors. Then they brace th' door of a car full of people. While
they climb up the steps they can't see inside, an' then they go an'
stick their heads in plain sight. It's an even break who sees th' other
first, with th' men inside training their guns on th' glass in th' door!"
"Darned if you ain't right!" enthusiastically cried the fat man.
Hopalong laughed: "It all depends on th' men inside. If they
ain't used to handling guns, 'course they won't try to fight. We 've
been in so many gun-festivals that we would n't stop to think. If any
coin-collector went an' stuck his ugly face against th' glass in that
door he 'd turn a back-flip off 'n th' platform before he knowed he
was hit. Is there any chance for a stick-up to-day, d'y think?"
"Can't tell," replied the brakeman. "But this is about the time we
have the section-camps' pay on board," he said, going into the
baggage end of the car.
Simms leaned over close to Skinny. "It's on this train now, and I
'm worried to death about it. I wish we were at Sandy Creek."
"Don't you go to worryin' none, then," the puncher replied. "It 'll
get to Sandy Creek all right."
Hopalong looked out of the window again and saw that there
was a gradual change in the nature of the scenery, for the plain was
becoming more broken each succeeding mile. Small woods
occasionally hurtled past and banks of cuts flashed by like mottled
yellow curtains, shutting off the view. Scrub timber stretched away
on both sides, a billowy sea of green, and miniature valleys lay
under the increasing number of trestles twisting and winding toward
a high horizon.
Hopalong yawned again: "Well, it's none o' our funeral. If they
let us alone I don't reckon we 'll take a hand, not even to bust up
this monotony."
Red laughed derisively: "Oh, no! Why, you could n't sit still
nohow with a fight going on, an' you know it. An' if it's a stick-up!
Wow!"
"Who gave you any say in this?" demanded his friend. "Anyhow,
you ain't no angel o' peace, not nohow!"
"Mebby they 'll plug yore new sombrero," laughed Red.
Hopalong felt of the article in question: "If any two-laigged wolf
plugs my war-bonnet he 'll be some sorry, an' so 'll his folks," he
asserted, rising and going down the aisle for a drink.
Red turned to the brakeman, who had just returned: "Say," he
whispered, "get off at th' next stop, shoot off a gun, an' yell, just for
fun. Go ahead, it 'll be better 'n a circus."
"Nix on the circus, says I," hastily replied the other. "I ain't
looking for no excitement, an' I ain't paid to amuse th' passengers. I
hope we don't even run over a track-torpedo this side of Sandy
Creek."
Hopalong returned, and as he came even with them the train
slowed.
"What are we stopping for?" he asked, his hand going to his
holster.
"To take on water; the tank 's right ahead."
"What have you got?" asked Billy, ruffling his cards.
"None of yore business," replied Lanky. "You call when you gets
any curious."
"Oh, th' devil!" yawned Hopalong, leaning back lazily. "I shore
wish I was on my cayuse pounding leather on th' home trail."
"Me, too," grumbled Red, staring out of the window. "Well, we
're moving again. It won't be long now before we gets out of this."
The card-game continued, the low-spoken terms being
interspersed with casual comment; Hopalong exchanged infrequent
remarks with Red, while the brakeman and conductor stared out of
the same window. There was noticeable an air of anxiety, and the fat
man tried to read his magazine with his thoughts far from the
printed page. He read and re-read a single paragraph several times
without gaining the slightest knowledge of what it meant, while the
dyspeptic passenger fidgeted more and more in his seat, like one
sitting on hot coals, anxious and alert.
"We 're there now," suddenly remarked the conductor, as the
bank of a cut blanked out the view. "It was right here where it
happened; the turn's farther on."
"How many cards did you draw, Skinny?" asked Lanky.
"Three; drawin' to a straight flush," laughed the dealer.
"Here 's the turn! We 're through all right," exclaimed the
brakeman.
Suddenly there was a rumbling bump, a screeching of air-brakes
and the grinding and rattle of couplings and pins as the train slowed
down and stopped with a suddenness that snapped the passengers
forward and back. The conductor and brakeman leaped to their feet,
where the latter stood quietly during a moment of indecision.
A shot was heard and the conductor's hand, raised quickly to
the whistle-rope sent blast after blast shrieking over the land. A
babel of shouting burst from the other coaches and, as the whistle
shrieked without pause, a shot was heard close at hand and the
conductor reeled suddenly and sank into a seat, limp and silent.
At the first jerk of the train the card-players threw the board
from across their knees, scattering the cards over the floor, and
crouching, gained the center of the aisle, intently peering through
the windows, their Colts ready for instant use. Hopalong and Red
were also in the aisle, and when the conductor had reeled
Hopalong's Colt exploded and the man outside threw up his arms
and pitched forward.
"Good boy, Hopalong!" cried Skinny, who was fighting mad.
Hopalong wheeled and crouched, watching the door, and it was
not long before a masked face appeared on the farther side of the
glass. Hopalong fired and a splotch of red stained the white mask as
the robber fell against the door and slid to the platform.
"Hear that shooting?" cried the brakeman. "They 're at the
messenger. They 'll blow him up!"
"Come on, fellers!" cried Hopalong, leaping toward the door,
closely followed by his friends.
They stepped over the obstruction on the platform and jumped
to the ground on the side of the car farthest from the robbers.
"Shoot under the cars for legs," whispered Skinny. "That 'll bring
'em down where we can get 'em."
"Which is a good idea," replied Red, dropping quickly and
looking under the car.
"Somebody's going to be surprised, all right," exulted Hopalong.
The firing on the other side of the train was heavy, being for the
purpose of terrifying the passengers and to forestall concerted
resistance. The robbers could not distinguish between the many
reports and did not know they were being opposed, or that two of
their number were dead.
A whinny reached Hopalong's ears and he located it in a small
grove ahead of him: "Well, we know where th' cayuses are in case
they make a break."
A white and scared face peered out of the cab-window and
Hopalong stopped his finger just in time, for the inquisitive man
wore the cap of fireman.
"You idiot!" muttered the gunman, angrily. "Get back!" he
ordered.
A pair of legs ran swiftly along the other side of the car and Red
and Skinny fired instantly. The legs bent, their owner falling forward
behind the rear truck, where he was screened from sight.
"They had it their own way before!" gritted Skinny. "Now we 'll
see if they can stand th' iron!"
By this time Hopalong and Red were crawling under the
express-car and were so preoccupied that they did not notice the
faint blue streak of smoke immediately over their heads. Then Red
glanced up to see what it was that sizzed, saw the glowing end of a
three-inch fuse, and blanched. It was death not to dare and his hand
shot up and back, and the dynamite cartridge sailed far behind him
to the edge of the embankment, where it hung on a bush.
"Good!" panted Hopalong. "We 'll pay 'em for that!"
"They 're worse 'n rustlers!"
They could hear the messenger running about over their heads,
dragging and up-ending heavy objects against the doors of the car,
and Hopalong laughed grimly:
"Luck's with this messenger, all right."
"It ought to be—he 's a fighter."
"Where are they? Have they tumbled to our game?"
"They're waiting for the explosion, you chump."
"Stay where you are then. Wait till they come out to see what's
th' matter with it."
Red snorted: "Wait nothing!"
"All right, then; I 'm with you. Get out of my way."
"I 've been in situations some peculiar, but this beats 'em all,"
Red chuckled, crawling forward.
The robber by the car truck revived enough to realize that
something was radically wrong, and shouted a warning as he raised
himself on his elbow to fire at Skinny but the alert puncher shot first.
As Hopalong and Red emerged from beneath the car and rose
to their feet there was a terrific explosion and they were knocked to
the ground, while a sudden, heavy shower of stones and earth
rained down over everything. The two punchers were not hurt and
they arose to their feet in time to see the engineer and fireman roll
out of the cab and crawl along the track on their hands and knees,
dazed and weakened by the concussion.
Suddenly, from one of the day-coaches, a masked man looked
out, saw the two punchers, and cried:
"It's all up! Save yourselves!"
As Hopalong and Red looked around, still dazed, he fired at
them, the bullet singing past Hopalong's ear. Red smothered a curse
and reeled as his friend grasped him. A wound over his right eye
was bleeding profusely and Hopalong's face cleared of its look of
anxiety when he realized that it was not serious.
"They creased you! Blamed near got you for keeps!" he cried,
wiping away the blood with his sleeve.
Red, slightly stunned, opened his eyes and looked about
confusedly. "Who done that? Where is he?"
"Don't know, but I'll shore find out," Hopalong replied. "Can you
stand alone?"
Red pushed himself free and leaned against the car for support:
"Course I can! Git that cuss!"
When Skinny heard the robber shout the warning he wheeled
and ran back, intently watching the windows and doors of the car for
trouble.
"We 'll finish yore tally right here!" he muttered.
When he reached the smoker he turned and went towards the
rear, where he found Lanky and Billy lying under the platform. Billy
was looking back and guarding their rear, while his companion
watched the clump of trees where the second herd of horses was
known to be. Just as they were joined by their foreman, they saw
two men run across the track, fifty yards distant, and into the grove,
both going so rapidly as to give no chance for a shot at them.
"There they are!" shouted Skinny, opening fire on the grove.
At that instant Hopalong turned the rear platform and saw the
brakeman leap out of the door with a Winchester in his hands. The
puncher sprang up the steps, wrenched the rifle from its owner, and,
tossing it to Skinny, cried: "Here, this is better!"
"Too late," grunted the puncher, looking up, but Hopalong had
become lost to sight among the rocks along the right of way. "If I
only had this a minute ago!" he grumbled.
The men in the grove, now in the saddle, turned and opened
fire on the group by the train, driving them back to shelter. Skinny,
taking advantage of the cover afforded, ran towards the grove,
ordering his friends to spread out and surround it; but it was too
late, for at that minute galloping was heard and it grew rapidly
fainter.
Red appeared at the end of the train: "Where's th' rest of the
coyotes?"
"Two of 'em got away," Lanky replied.
"Ya-ho!" shouted Hopalong from the grove. "Don't none of you
fools shoot! I'm coming out. They plumb got away!"
"They near got you, Red," Skinny cried.
"Nears don't count," Red laughed.
"Did you ever notice Hopalong when he 's fighting mad?" asked
Lanky, grinning at the man who was leaving the woods. "He allus
wears his sombrero hanging on one ear. Look at it now!"
"Who touched off that cannon some time back?" asked Billy.
"I did. It was an anti-gravity cartridge what I found sizzling on a
rod under th' floor of th' express car," replied Red.
"Why did n't you pinch out th' fuse 'stead of blowing everything
up, you half-breed?" Lanky asked.
"I reckon I was some hasty," grinned Red.
"It blowed me under th' car an' my lid through a windy," cried
Billy. "An' Skinny, he went up in th' air like a shore-'nough
grasshopper."
Hopalong joined them, grinning broadly: "Hey, reckon ridin' in
th' cars ain't so bad after all, is it?"
"Holy smoke!" cried Skinny. "What's that a-popping?"
Hopalong, Colt in hand, leaped to the side of the train and
looked along it, the others close behind him, and saw the fat man
with his head and arm out of the window, blazing away into the air,
which increased the panic in the coaches. Hopalong grinned and
fired into the ground, and the fat man nearly dislocated parts of his
anatomy by his hasty disappearance.
"Reckon he plumb forgot all about his fine, six-dollar gun till just
now," Skinny laughed.
"Oh, he 's making good," Red replied. "He said he 'd take a
hand if anything busted loose. It's a good thing he did n't come to
life while me an' Hoppy was under his windy looking for laigs."
"Reckon some of us better go in th' cars an' quiet th'
stampede," Skinny remarked, mounting the steps, followed by
Hopalong. "They're shore loco."
The uproar in the coach ceased abruptly when the two punchers
stepped through the door, the inmates shrinking into their seats,
frightened into silence. Skinny and his companion did not make a
reassuring sight, for they were grimy with burned powder and dust,
and Hopalong's sleeve was stained with Red's blood.
"Oh, my jewels, my pretty jewels," sobbed a woman, staring at
Skinny and wringing her hands.
"Ma'am, we shore don't want yore jewelry," replied Skinny,
earnestly. "Ca'm yoreself; we don't want nothin'."
"I don't want that!" growled Hopalong, pushing a wallet from
him. "How many times do you want us to tell you we don't want
nothin'? We ain't robbers; we licked th' robbers."
Suddenly he stooped and, grasping a pair of legs which
protruded into the aisle obstructing the passage, straightened up
and backed towards Red, who had just entered the car, dragging
into sight a portly gentleman, who kicked and struggled and
squealed, as he grabbed at the stanchions of seats to stay his
progress. Red stepped aside between two seats and let his friend
pass, and then leaned over and grasped the portly gentleman's coat-
collar. He tugged energetically and lifted the frightened man clear of
the aisle and deposited him across the back of a seat, face down,
where he hung balanced, yelling and kicking.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like