Clojure Programming Cookbook Makoto Hashimoto Nicolas Modrzyk download https://ebookbell.com/product/clojure-programming-cookbook- makoto-hashimoto-nicolas-modrzyk-6810064 Explore and download more ebooks at ebookbell.com
Here are some recommended products that we believe you will be interested in. You can click the link to download. Clojure Programming 1st Edition Chas Emerick Brian Carper Christophe Grand https://ebookbell.com/product/clojure-programming-1st-edition-chas- emerick-brian-carper-christophe-grand-2546580 Clojure Programming Chas Emerick Brian Carper Christophe Grand https://ebookbell.com/product/clojure-programming-chas-emerick-brian- carper-christophe-grand-53638812 Clojure Programming Chas Emerick Brian Carper Christophe Grand https://ebookbell.com/product/clojure-programming-chas-emerick-brian- carper-christophe-grand-47032898 Clojure Programming Chas Emerick Brian Carper And Christophe Grand https://ebookbell.com/product/clojure-programming-chas-emerick-brian- carper-and-christophe-grand-31644322
Clojure Programming Chas Emerick Brian Carper Christophe Grand https://ebookbell.com/product/clojure-programming-chas-emerick-brian- carper-christophe-grand-43034508 Clojure Reactive Programming Leonardo Borges https://ebookbell.com/product/clojure-reactive-programming-leonardo- borges-43038448 Clojure Reactive Programming Leonardo Borges https://ebookbell.com/product/clojure-reactive-programming-leonardo- borges-5035770 Clojure Reactive Programming Design And Implement Highly Reusable Reactive Applications By Integrating Different Frameworks With Clojure Borges https://ebookbell.com/product/clojure-reactive-programming-design-and- implement-highly-reusable-reactive-applications-by-integrating- different-frameworks-with-clojure-borges-10614742 Clojure Reactive Programming Leonardo Borges https://ebookbell.com/product/clojure-reactive-programming-leonardo- borges-43192084
Clojure Programming Cookbook
Table of Contents Clojure Programming Cookbook Credits About the Authors About the Reviewer www.PacktPub.com eBooks, discount offers, and more Why subscribe? Preface What this book covers What you need for this book Who this book is for Sections Getting ready How to do it… How it works… There's more… See also Conventions Reader feedback Customer support Downloading the example code Downloading the color images of this book Errata Piracy Questions 1. Live Programming with Clojure Introduction REPL up! Getting ready How to do it... How it works... There's more...
See also Working with primitive data types Getting ready How to do it... Using numbers Using strings and characters Using booleans and nil Using symbols and keywords How it works... There's more... Using bindings of vars, conditions, loops, and error handling Getting ready How to do it... def and let if and if-not when and when-not case and cond do and dotimes loop and recur try... catch... throw How it works... Using and defining functions Getting ready How to do it... Defining simple functions Defining variadic functions Defining multiple arity functions Defining functions that specify arguments using a keyword Defining functions with pre-condition and post-condition How it works... There's more... Using third-party libraries Getting ready How to do it... Adding the JAR file manually to your classpath Using Leiningen and a project.clj file
Viewing dependencies one-off New dependencies at runtime Using namespaces Getting ready How to do it... Creating a new namespace Inspecting namespaces Adding functions with :import and :refer Loading namespaces from files Reloading namespaces How to organize namespaces There's more... Namespace for public API tools.namespace What's next? 2. Interacting with Collections Introduction Clojure collections and their basic functions Getting ready How to do it... Lists Vectors Maps Sets How it works... Clojure collections Differences between lists and vectors Clojure is immutable There's more... Converting collections between different types Using distinct Accessing and updating elements from collections Getting ready How to do it... Accessing collections using the nth function
Accessing maps or sets using get Maps, sets, and keywords are functions to access collections Accessing a collection using second, next, ffirst, and nfirst Using update to update collections How it works... There's more... Using get for vectors Using collections as keys in maps Using get-in Using assoc-in Using update-in Filtering elements from collections Getting ready How to do it... Filtering multiples of three Filtering items of a map Filtering non-nil values Removing odd values from a sequence Using keep Using keep-indexed There's more... Filter as a transducer Filtering with core.async Transforming and sorting collections Getting ready How to do it... Using built-in sort Migrating to sort-by Using sorted-set Working with sorted collection subsets Sorting Clojure maps Sorted map structure Are you sorted yet? How it works... There's more... Sorting lines of a file
Merging and splitting collections Getting ready How to do it... Using merge and merge-with for merging The zipmap merges keys and values for maps Using interleave Using split-at and split-with to split collections How it works... There's more... Using group-by to split collections Using the filter function to split collections How to become lazy Getting ready How to do it... The iterate function Realized? Random sequences with repeatedly Using the macro lazy-seq How it works... There's more... Other lazy-seq-producing functions Force evaluation with doall Lazy evaluation with files The map function and calling rest 3. Clojure Next Introduction Using destructuring techniques Getting ready How to do it... Sequential destructuring Using map destructuring How it works... There's more... Sequential destructuring for string Conditional destructing with core.match Using functional programming style
Getting ready How to do it... Functions taking functions as their arguments map reduce apply Using anonymous functions Anonymous functions using fn Using function literals to define anonymous functions Functions returning functions constantly complement partial comp every-pred and some-fn How it works... Clojure functions are first-class functions Pure functions There's more... reduce and apply loop and recur Using threading macros Getting ready How to do it... Introducing the -> macro Introducing the ->> macro Introducing the cond-> and the cond->> macros Introducing some-> and some->> How it works... There's more... Introducing as-> Flambo preview Defining simple macros Getting ready How to do it... Your first macro
Your second macro How it works... There's more... Using quotes Macros everywhere Defining more advanced macros Getting ready How to do it... Tracking when code was started Logging a message with macro How it works... There's more... deftest Using protocols Getting ready How to do it... Defining a record Defining a type Defining a protocol How it works... Records and types are Java classes Differentiating between records and types There's more... Defining a mutable protocol and type Defining multimethods Getting ready How to do it... Defining a multimethod How it works... There's more... Transducers for dummies Getting ready How to do it... How it works... Composable functions Inserting elements
Writing your own transducers Short circuit There's more... Transducers with core.async Summing things up Logic programming in Clojure Getting ready Baby logic steps Getting to know the "o" vocabulary conso: check for vector association resto: check for the rest of a vector membero appendo: appending list conde Matche Beginner logic Keeping fresh Finding only one result Mature logic Range of values How to do it... Generating data Generating more data with more logic variables Using a project How it works... There's more... Validating the results of a function Working with external data 4. File Access and the Network Introduction Manipulating files and directories Getting ready How to do it... spit and slurp Reader and writer with with-open Creating a file and directory
Copying a file Deleting a file and a directory Listing files and directories in a directory How it works... slurp and spit with-open macro There's more... Reading HTTP resource Examining the source code Manipulating various formats of files - XML, JSON, YAML, and EDN Getting ready How to do it... XML JSON YAML isn't a markup language MessagePack, Clojure library How it works... There's more... Extensible Data Notation Making use of Clojure HTTP client Getting ready How to do it... How it works... There's more... async HTTP and core async Using queues and topics in the RabbitMQ Getting ready Installing RabbitMQ How to do it... Producing hello world messages and consuming them Declaring the namespace and loading Langohr libraries and IP address of the Docker container Defining a producer function Defining a message handler and consumer Testing producer and consumer
Using blocking consumer How it works... Connect to broker and open channel How producer works Declaring queue Producing messages How consumer works Consumer messages Defining message handler There's more... Using fanout exchange fanout-producer fanout-consumer Running the fanout consumers Testing fanout consumers Using topic exchange Topic-publisher Topic-consumer Running the topic consumers Testing the topic consumers See also Using Kafka Getting ready Downloading Kafka 0.8.2.2 Start ZooKeeper and Kafka server Create topic Run a console consumer Using clj-kafka How to do it... Declaring the namespace and load Clojure library Producing messages Consuming a messages How it works... Producing messages Consuming messages There's more...
Creating a new topic See also Using MQTT Getting ready Installing the MQTT broker MQTT graphical client Send our first MQTT message Getting some Clojure How to do it... How it works... There's more... Streaming access to provide high performance Getting ready How to do it... Streaming out Streaming in Streaming with line-seq How it works... There's more... Using Apache Camel to connect everything Getting ready How to do it... Importing Camel classes Your first ride on Camel with Clojure Writing more Clojure idiomatic code with Camel How it works... There's more... See also 5. Working with Other Languages Introduction Calling Java methods and accessing Java objects from Clojure Getting ready How to do it... Instantiating objects Calling instance methods Calling class methods
Accessing instance fields Accessing class fields Accessing inner classes Referencing classes Using arrays How it works... Summary of how Clojure accesses Java methods and objects Clojure does not inherit Java's checked exception Summary of array accesses Print strings of Java's primitives There's more... Chained calls with the double-dot macro Using the doto macro Using reflections Extending Java superclasses and implementing Java interfaces Getting ready How to do it... Using proxy Using reify for implementing interfaces How it works... There's more... Defining anonymous classes in Clojure Using annotations Calling Clojure from Java Getting ready How to do it... Defining a simple named class using gen-class Defining a class with instance methods and constructors in Clojure Creating a JAR file callable from Java How it works... The project.clj for generating Java classes AOT compilation There's more... Defining an interface and implementing a class callable from Java
Using Maven for Clojure and Java projects Calling Scala from Clojure Getting ready How to do it... Using Leiningen to develop Scala and Clojure Importing Scala classes Calling instance methods Calling singleton methods Accessing tuples Accessing Scala fields How it works... There's more... Using SBT Creating an SBT-based project Writing source code ClojureCLR Getting ready Installing Visual Code Studio and creating a project Installing Mono Studio IDE Lein CLR How to do it... Calling .NET code from Clojure Starting an REPL Working with IO Parsing some XML using C# code Calling a REST API using Clojure/C# UI Prototyping Putting it all together How it works... Compiling Clojure code for .NET Adding Clojure code to a Visual Studio project Running Clojure code using Clojure.RT Using Xamarin Mono Studio There's more... ClojureScript Getting ready
How to do it... Autocompiling your code Fibonacci'ed How it works... Interacting with JavaScript Using jQuery from ClojureScript Creating a ClojureScript library Using a third-party library There's more... Running in the REPL Compiling code for both Clojure and ClojureScript 6. Concurrency and Parallelism Introduction Solving concurrent problems using Clojure Getting ready How to do it... Using atoms Creating and referring atom Updating atom Using validator Using CAS operation Software Transactional Memory using ref and dosync Creating ref Updating refs using alter Using ensure Using watcher and a refined transaction code Using commute Using agents Creating agents Updating agents How it works... Summary of three reference types in Clojure Coordinated/uncoordinated Synchronous/asynchronous How STM works in Clojure Alter and commute
There's more... promise and deliver pmap, pcalls, and pvalues pcalls pvalues See also Distributed actor-based dev with Akka Getting ready How to do it... Your first okku Creating actors Dispatching messages How it works... Actor system Understanding actors There's more... Calling remote actors Request and reply See also Using Spyglass and Couchbase to share state between JVMs Getting ready Setting up dependencies in project.clj Setting up Couchbase Server as a Memcached server Using docker-compose to start Couchbase Server Creating a directory and a file for docker-compose Start Couchbase cluster Check if Docker processes are running Summary of Couchbase cluster Using Couchbase web administrator console Logging into the web console Adding nodes to the cluster Adding Cluster Defining Memcached bucket How to do it... Defining to use Spyglass library Connecting server
Set values Get values from another REPL Testing time to live Disconnecting How it works... What is Memcached? Access Memcached from Telnet Couchbase Server There's more... Using get-multi Using async-get Using CAS operations See also Reactive programming with meltdown Getting ready How to do it... Defining a reactor Sending a message to a reactor Going the sync way How it works... Selectors Streams Streams and reduce Combining functions with a graph Custom streams There's more... Bridging core.async Getting ready Memories - reviewing core.async basics Pub/sub How to do it... Async socket server Async socket client Chiming There's more... Client to Python WebSockets
Clojure WebSocket server On Quasar/Pulsar Getting ready How to do it... How it works... Watching over other actors lifecycles State of an actor There's more... Blazar 7. Advanced Tips Introduction Hacking the Clojure code Getting ready How to do it... How it works... There's more... Using Reader Conditionals, compile to Clojure, and ClojureScript Getting ready How to do it... Your first Reader Conditional Using Reader Conditionals in namespaces How it works... The form of Reader Conditionals and Splice macros Macros in ClojureScript There's more... Building an application for Clojure and ClojureScript Adding a cljc file for demonstrating Quil Testing cljc code in both Clojure and ClojureScript Building and running a demo See also Real-time shared development with an REPL Getting ready How to do it... Shared REPLs Using Atom and proto-repl Using an embedded NREPL
There's more... Custom REPL using Java interop Server Client The async custom REPL server Server REPL or more on real-time work on production code Declarative data descriptions and validations with plumatic/schema Getting ready How to do it... My first schema Using schema for records and other types Defining functions with validations How it works... Performance considerations Generating test data There's more... Data coercion with prismatic/schema Using core.typed core.spec 8. Web Applications Introduction Clojure with Vaadin - easy web widgets Getting ready Project settings The Clojure/Vaadin flow How to do it... Using the Calendar widget Reacting to events Clicking a button Using and reloading namespaces Server-side push There's more... Reactive Vaadin - ideas Reactive Vaadin - CPU monitoring Reactive Vaadin - Telegram on Raspberry Pi Deployment bonus
Quickly create a REST API with Liberator Getting ready How to do it... Your first Liberator Using defresource Parameterized resources Defining GET/POST/PUT/DELETE methods for REST APIs How it works... Methods and status codes of HTTP Tracing requests There's more... Persistent REST resources using clojure.java.jdbc Preparing for jdbc Our service spec Creating a product table and defining access functions Defining resources and starting a server Accessing from an HTTP client Working with Immutant - reusing infrastructure Getting ready How to do it... Simple messaging with Artemis Remote messaging Remote procedure call with queues Scheduling code execution Piping and defining data transformation pipelines Using WebSockets made easy There's more... Packaging as standalone Packaging as a deployable web archive (WAR file) Developing with om.next, the next-generation ClojureScript library Getting ready Creating a new project for om.next Updating the om version Tips for dependencies Starting figwheel How to do it...
Getting started with om.next Using states How it works... React fundamentals defui reconciler Life cycle of components There's more... Task list using om.next Defining the namespace and libraries to use Defining state Defining read Defining mutate Defining UIs 9. Testing Introduction Behavior-driven development Getting ready Dependencies The first feature Designing a folder structure to organize features How to do it... Many assumptions with tables Reading assumptions from a CSV file Doing it with Excel Doing it with web APIs and MongoDB There's more... VirtualBox Freactive Flambo, or BDD meets Apache Spark EEP for BDD OpenCV Testing with random inputs and pattern-based testing Getting ready Libraries Generating random values or groups of values
Random values based on schema How to do it... Your first test.check specification Auto-running tests More specifications and generators Generators and de-structuring Herbert There's more... Benchmarking with Criterium, performance tips, and other tools Getting ready How to do it... Using Criterium How it works... Type hints Using appropriate data types Maps versus records versus types Primitive arrays Working with transient data structures Memoize functions There's more... Logging with timbre and profiling with tufte Using jvisualvm 10. Deployment and DevOps Introduction Riemann - monitoring deliverance and slacking Getting ready Installing the Riemann service Configuring the Riemann daemon The Riemann dashboard Riemann-health Just enough dashboard configuration Preparing to send events How to do it... Basic event reporting for a service Expiring events How it works...
There's more... From Riemann to Slack webhooks From Slack bots to Riemann Deploying Clojure with Docker Getting ready Installing Docker on OS X or Windows Installing Docker on Debian Preparing the Clojure application Packaging the application into a JAR file Creating the Docker container How to do it... Connecting directly to a remote Docker There's more... Clojure on Amazon Web Services Getting ready Signing up on AWS Getting the access key and secret access key Setting up dependencies in your project.clj How to do it... Using EC2 Using S3 Using Amazon SQS Serverless Clojure with AWS Lambda Clojure namespace helloworld Hello World - the AWS part Hello Stream Real-world Lambdas How it works... What is Amazon EC2? Amazon S3 Buckets and keys Objects There's no more...
Clojure Programming Cookbook
Clojure Programming Cookbook Copyright © 2016 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: October 2016 Production reference: 1211016 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78588-503-7
www.packtpub.com
Credits Authors Makoto Hashimoto Nicolas Modrzyk Copy Editors Safis Editing Sameen Siddiqui Reviewers Eduard Bondarenko Dmitri Sotnikov Project Coordinator Ritika Manoj Commissioning Editor Kartikey Pandey Proofreader Safis Editing Acquisition Editor Kirk D'costa Indexer Tejal Daruwale Soni Content Development Editor Sachin Karnani Graphics Abhinash Sahu Technical Editor PranavKukreti Production Coordinator Aparna Bhagat
About the Authors Makoto Hashimoto is a technical enthusiast in Japan. He has been involved in a lot of projects as an IT architect and led them successfully with his technical leadership. Makoto loves programming, especially with functional programming languages. Thus, he became an enthusiast of Clojure since his first encounter with this language. Recently, he is often involved in projects of the big data domain, and he constantly thinks up new ways to use Clojure for this domain. He loves spending time with his family during weekends and apart from that he loves cooking, classical music, arts and sports. Makoto has also written two books in Japanese. You can find them at http://amzn.to/2e0jySv and http://amzn.to/2eg3gq8. To my coauthor, Nicolas, working with you has been a great honor for me. Many thanks for your valuable advices and encouragements.To my family, I would like to thank my family and friends for their constant encouragements and support. Without you, there is no way that I would have been able to complete this work. Nicolas Modrzyk has many years of experience in the field of IT and has spent many years in Asia. He loves making ideas a reality and the fact that this reality brings people from all around the planet together. He's been involved in many IT projects, helping customers reach their goal and in general trying to make IT easier to reach for everyone. Nicolas fell into the Clojure soup 5 years ago; it helped him become more focused, and stop wasting time on the things that are not worth it. Clojure is more than just a fantastic programming language; it is a life full of adventure. Hopefully, this book takes you on the road to that adventure. Nicolas has also written a book, Oishii Clojure (http://gihyo.jp/book/2013/978-4-7741-5991-1), in Japanese,
with plenty of short Clojure recipes to enjoy the Clojure language and to make you want to try new things. Thank you, Makoto, for reaching out and making this book a fantastic adventure! Also, I'm looking forward to our next one! To my daughters, Mei and Manon, I think about you always, even during those late nights spent working on the book. To my loving family and awesome friends, for their continuous support, even in those times when I only talk about Clojure.
About the Reviewer Eduard Bondarenko is a long-time Ruby and Clojure programmer. He got into Android development recently. He prefers concise and expressive code with some comments, and has tried many programming languages, such as Python, Erlang, Nodejs, Elm, Scala, and others. Eduard has reviewed a couple of Clojure books, and he liked all of them for their interesting and broad topics. Besides programming, he likes to spend time with his family, play soccer, and travel. I want to thank my family for supporting my desire to work on the book, and the authors for the demonstration of different and extraordinary applications of Clojure.
www.PacktPub.com eBooks, discount offers, and more 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 customercare@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
Preface This is a book designed to make you want to try things. It will take you back to the days when you had tons of energy and were ready to just start and make things happen. Clojure is a one of a kind programming language, where the core is very important, and you can just write efficient code, based on strong building blocks. With the upcoming release of Clojure 1.9, this language is ahead of other languages due to its simplicity and conciseness. So whether you are embarking on a weekend programming project with Raspberry Pi or getting ready to challenge the world with your new start-up, the tons of good recipes provided in this book are for you. This book can mostly be read in any order, but make sure that you go through the first few recipes to review the basics of Clojure. Make things happen and enjoy every piece of it. What this book covers Chapter 1, Live Programming with Clojure, helps you review how the Clojure basics work with different data types, how the code control flows, and also how to integrate third-party libraries. You probably know this already, but you simply cannot start a good cookbook without a strong base. Chapter 2, Interacting with Collections, covers selecting, filtering, transforming, merging, joining, and how to become lazy. Laziness is one of the greatest Clojure feature, and we want to make sure that you will always be lazy enough. Chapter 3, Clojure Next, introduces you to macros, advanced macros, transducers (what transducers are, anyway), and logic programming. It
covers preprocessing and postprocessing of Clojure data as code features. Chapter 4, File Access and the Network, covers StreamingQueues and real-time networking, which gives you the power to think about distributed systems and how to connect your IoT devices. It also covers files and how to manipulate files to help you with lightweight processing for interconnections. Chapter 5, Working with Other Languages, introduces you to the basic Clojure tooling that allows you to easily integrate code written in other languages, such as Java, Scala, and .NET, all the way to Clojure on the JavaScript runtime, ClojureScript. Chapter 6, Concurrency and Parallelism, helps you learn multiple ways of splitting jobs among Clojure processes, interacting with Scala-like actors, and to also sharing states between different instances. Of course, this chapter covers the simplest way of writing a parallel code in Clojure, core.async. Chapter 7, Advanced Tips, helps you if you want to know how to perform not only pair programming but also shared real-time pair programming. You will also see how to hack the Clojure source code yourself. Chapter 8, Web Applications, takes you through web applications, web services, or API endpoints or whatever you call them. You also learn how to use nice-looking widgets with Vaadin, how to write rest-like APIs with Liberator, and use Immutant, a set of server-side services at the finger of your Clojure code. Chapter 9, Testing, not only helps you with validating your code but also with using random pattern testing for the cases you had not thought about. This chapter also introduces behavior-driven development in Clojure with some OpenCV validation, and finally, explains how to benchmark the speed of your code.
Chapter 10, Deployment and DevOps, covers dockerizing your Clojure code, making it run locally as it would in the Cloud, putting real-time monitoring in place for your critical services, and finally, your favorite Amazon tricks are also covered here.
What you need for this book You need a bit of time, a computer, and a text editor. That's all this book requires. Of course, previous functional programming experience is a big plus, but having motivation and energy is pretty much all you need.
Who this book is for This book is for people who want to make things happen. Follow along the lines of the zillions of code samples included in this book, and go ahead from there. Each example should make you want to try things around, and bring up some new ideas. This book should start by being just a cookbook, but by the end, will become your cookbook.
Sections In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also). To give clear instructions on how to complete a recipe, we use these sections as follows: Getting ready This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe. How to do it… This section contains the steps required to follow the recipe. How it works… This section usually consists of a detailed explanation of what happened in the previous section. There's more… This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe. See also This section provides helpful links to other useful information for the recipe.
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: "However, declaring libraries in project.clj is much simpler than doing it in the pom.xml file of Maven." A block of code is set as follows: String str = "Hello ".concat("world !"); Any command-line input or output is written as follows: $ mv lein ~/bin 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: "Go to the Data Buckets tab and click on the Create New Data Bucket option." Note Warnings or important notes appear in a box like this. Tip 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. Downloading the example code You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and 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. You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account. 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/PacktPublishing/Clojure-Programming-Cookbook. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. 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/downloads/ClojureProgrammingC 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/content/support and 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.
Chapter 1. Live Programming with Clojure In this chapter, we will cover the following topics: REPL up! Working with primitive data types Using bindings of vars, conditions, loops, and error handling Using and defining functions Using third-party libraries Using namespaces Introduction Clojure is a blend of Lisp and Java. Clojure allows you to solve what you want quickly and keeps code simple. Once you learn Clojure, it's great fun to use it! Clojure provides the following fantastic features: Clojure is a dialect of Lisp and supports the functional programing style It runs on Java Virtual Machine (JVM) and can use Java's assets seamlessly It also supports immutability and concurrent programming In this chapter, we will review how to set up a Clojure REPL environment and Clojures' basic structure, including primitive data types, programming flow controls, and functions. Then we will go over how to use third-party libraries and namespaces. Let's take you to Clojure's fantastic world; we'll begin with REPL up!
REPL up! REPL is the interpreter of Clojure, and it is an acronym of Read Evaluate Print Loop. Unlike other interpreter languages, such as Python or Ruby, Clojure REPL automatically compiles into Java's byte code after the reading expression. Then, REPL evaluates the expression and returns the result of the expression. This dynamic compilation feature of REPL makes Clojure code execution as fast as executing pre- compiled code. Getting ready Before you set up your Clojure environment, the Java Development Kit (JDK) is necessary. The JDK version should be 1.6 or later. Throughout the book, we will use JDK 1.8 to develop and test the code. This is how the command-line result will look, once you type java - version: How to do it... Leiningen is a standard build tool for Clojure. It simplifies the Clojure development, including setting up your project, compiling and testing code, and creating libraries for deployment. It's easy to set up a Clojure environment using Leiningen. There are only
a few steps before you can enjoy Clojure in REPL! Here are the steps we need to perform to run Clojure REPL: 1. Download and set up Leiningen from http://leiningen.org/. 2. Download the lein script (or on Windows, lein.bat). 3. Place it on your $PATH where your shell can find it (for example, ~/bin): $ mv lein ~/bin 4. Set it to be executable: $ chmod a+x ~/bin/lein 5. Run lein, and it will download the self-install package:
6. Create a new project and go there. Using Leiningen, you can create a project from a project template. This example creates a project called living-clojure: $ lein new living-clojure 7. Run REPL and put Clojure code into it:
How it works... Here is a very simple code to demonstrate how REPL works. This code simply loops forever with read, eval, and println functions: user=> (defn simple-repl [] #_=> (try #_=> (while true #_=> (println (eval (read))) #_=> ) #_=> (catch Exception e (println "exited..")) #_=> ) #_=> ) #'user/simple-repl user=> (simple-repl) (+ 1 1) 2 (defn hello [s] (println "Hello world " s)) #'user/hello (hello "Makoto") Hello world Makoto nil exited.. nil user=>
You can exit simple-repl by entering ^D (Ctrl + D). There's more... Leiningen is a very powerful tool for Clojure developers. The lein new living-clojure command generates the following directory structure: Let's pick up project.clj, which defines the project: (defproject living-clojure "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.8.0"]]) In project.clj, the :dependencies section declares the libraries used by your project. Leiningen internally uses Maven to solve the dependencies of libraries.
However, declaring libraries in project.clj is much simpler than doing it in the pom.xml file of Maven. To use other libraries for your project, add them to the dependency section. We will review how to do this in a later recipe. In the preceding project.clj file, the Clojure library named org.clojure/clojure is declared and automatically downloads in the maven directory. This is the reason why you don't need to download and set up the Clojure library explicitly. Without Leiningen, you have to do it in a more native way. Here are the steps: 1. Download clojure-1.8.0.jar. 2. Download clojure-1.8.0.jar using wget: $ wget http://repo1.maven.org/maven2/org/clojure/clojure/1.8.0/ clojure-1.8.0.jar 3. Run Clojure and test the Clojure code: $ java -jar clojure-1.8.0.jar Clojure 1.8.0 user=> (+ 1 1) 2 REPL supports the command-line editing feature, like Linux bash shell does, but the preceding way does not. Another difference is that REPL solves library dependency problems in project.clj, but using the native
Exploring the Variety of Random Documents with Different Content
Chapter Fourteen. At Dinner. “Hold your tongue, boy! Don’t contradict me. You’re not to think because your father is dead that you are going to do just as you like. Try some more of that claret; it’s very good. There were only fifty dozen of it, and your father and I shared the lot. I suppose you’ve got some of it left in the cellar—your cellar. Dear, dear! poor old Grantham, what a change! There, fill up your glass. That won’t hurt you. I say it as a medical man. That’s wine that maketh glad the heart of man; and one needs it now, for homes desolate enough. The miserable jade!” “It was not her fault,” said Clive sadly. “What! I say it was her fault, so don’t you defend her. Confound you, sir, I know you’ve grown into a big, ugly, consequential fellow; but recollect this, sir, I consider I take your father’s place now he’s gone. I’m the first man who ever held you in his hands. Didn’t I vaccinate you, and bring you through half-a-dozen miserable little baby disorders? You are Clive Reed, mine-owner and rich man to the world; but you are only the squalling brat and scrubby boy, sir, to me.” The Doctor tossed off a glass of his rich claret, and then swung himself round in his chair. “Don’t take any notice of what I say, boy. I’m not myself.” Clive rose from his chair and went and laid his hand upon the Doctor’s shoulder, to have it seized and held.
“My dear old friend!” he said, in a low voice. “Thank you, my boy, thank you. God bless you! I seem to have no one but you—now she’s gone. Clive, my lad, I’ll tell you. I came back here after the funeral and went into the drawing-room, and I turned her picture with its face to the wall, after I’d cursed her like old fathers used to do in the plays when I was a boy. I said I cast her off for ever; and then I sat down in my chair, and did what I hadn’t done since her mother, my poor dear wife, died. I cried, boy, like a little child. For it seemed as if she was dead too—dead and gone—and I had suddenly turned into a disappointed, lonely old man.” “And then you turned the picture back, and owned to yourself that you loved her very dearly still, as I do, sir. For we cannot tear our affections up by the roots like that.” “I did, Clive, my boy, I did; for you are right. I know too now that it’s my own fault, for I spoiled and indulged her. She was left to me almost a child, motherless, and I began to treat her at once as a woman. I let her have her own way in everything, and she grew up pettish and jealous, and ready to resent every check. Times and times, when I’ve offended her, has she gone right off on a visit, just to annoy me, and show how independent she was. But there! it’s all over now.” “Yes,” said Clive softly, “it’s all over now.” “And how I used to reckon upon it all!” continued the Doctor. “You two married, and the little children springing up—hers and yours, boy, to make my old life young again. But it’s all over. I won’t say I’ll never see her again, but I’ve done with her; and as for that miserable, cunning, unprincipled scoundrel, how long will it be before he’s laid
up with D.T., or something worse—if there is anything worse? I’ll go and attend him gratis, and pay for his funeral afterwards with pleasure.” “No, no, not you,” said Clive quietly. “I will, sir; I shall consider it a duty to that poor girl to make her a widow as soon as possible, so that she may live in peace and repent.” Clive shook his head. “The man she loves,” he said softly. “She doesn’t; she can’t love such a scoundrel. The brainless, little, thoughtless idiot! She believed all that of you directly, and ran off to marry the blackguard who has been trying for weeks to undermine you, so as to get my money. Why, I find he has been constantly coming here to see her, and she in her vanity played with him—a little coquette—played with the confounded serpent, till he wound round and stung her.” Clive hung his head. “And all the time you and I would have been ready to knock the man down who had dared to suggest that she was trifling with you. Bah! they’re a poor, weak, pitiful lot, the women, Clive. I’ve doctored enough of them to know all their little weaknesses, my lad. A poor, pitiful lot!” “Do you think so?” said Clive quietly. “Well, some of them. But, by jingo, boy, what a punishment for the designing scoundrel. He had heard poor old Grantham let drop that he had put Janet—I mean that girl— down for a big sum, and he played for it—gambled. He
meant that. By jingo! his face when he found he had lost! I’m going to let you know, too, what I have done.” “What have you done?” said Clive, rather anxiously. “Made a new will, sir, and had the old one burned before my eyes. I’ve gone on saving for that girl, and the money’s hers, and she shall have it when I die; but he shan’t. I went to old Belton, told him what I wanted, and he went into it con amore, for he dislikes Master Jessop consumedly. He says it’s a natural reversion—the harking back to a bad strain that once got into the Reed blood.” “But what did you do?” said Clive. “Do, boy! tied the money up as tight as the law can tie it. My little bit is to be in the hands of trustees, and she will get the dividends, but she cannot sell out and give the money to your blackguard of a brother; and in a very short time he’ll know it, begin to ill-use her, and go on till she shows that she has some spirit, and then she’ll turn upon him, there’ll be a row, and she’ll come home.” Clive sat frowning. “It will be my revenge upon the scoundrel. I say, by the way, that little parlour-maid, Lyddy, what about her?” “I know nothing,” said Clive sadly. “The scoundrel has spirited her away somewhere, I suppose. Ah! well, they’ll make him suffer for it in the long- run, and you and I will have a pretty revenge. There now, not another word about either of them. You told me you were going down to Derbyshire again.” “Yes, to-morrow.”
“That’s right! Go and work, my lad. You won’t do it merely for the money, but to carry out my poor old friend’s wishes. You’ve got to make that mine a very big success. I’ve put a lot in it, my boy, so you mustn’t let me lose. I mean to take up what Byron calls a good old gentlemanly vice—avarice. Don’t be down-hearted, boy. Have another glass of claret, and we’ll drink to your success. One of these days I shall come and drink your bride’s health. Some true, sweet girl, whom I can call daughter. Ah! you shake your head now, because you have just been to the funeral of your coming hopes. But wait a bit, my boy. The world turns round, and after the winter the summer comes again.” Clive Reed sighed, and at that hour, sick and sore at heart, and despairing, as much on account of the woman he loved as upon his own, everything ahead looked black but the prospect of his late father’s venture, and over this he now set himself to work; not to make money, for he had plenty, but to dull the gnawing pain always busy at his heart.
Chapter Fifteen. The Undercurrent. “Hah! I nearly had you that time, my fine fellow,” said Major Gurdon, as he stood deep in the shade, where twilight was falling fast, and ever and anon he deftly threw a fly with his lissome rod right across to the edge of the black water, where the deep suddenly grew shallow, and a sharp rippling was made by the swiftly flowing stream. “Feel it chilly, my dear?” he said, as he made the brass winch chirrup as he drew out more line. “No, dear,” said Dinah, with her pale, troubled face lighting up, as she stood there holding a landing-net. “It is very beautiful and cool and pleasant now.” “Ah! that sounds better,” said the Major, as he made his fine line whish through the air and sent the fly far away down- stream. “You have been fidgeting me, my dear.” “I, papa?” said the girl hurriedly. “Yes. You haven’t seemed the same since you had that fall.” “Oh, it was nothing much, dear.” “But it was a good deal to make you look so white and upset ever since.—Missed him!—Do you know, my dear,” continued the Major, making another throw, “I lay awake half last night thinking that I ought to take you up to London to see some clever physician.”
“Oh, no, no, no,” said the girl hurriedly. “You shouldn’t fidget about that. I am better. I am, indeed.” “Then impossibilities have come to pass, and your little face is deceitful.” “You take too much notice of things, dear,” said Dinah, shrinking a little behind her father, so as to hide the fresh shade of trouble in her countenance. “Oh no, I don’t,” said the Major, as he threw his fly again. “I have not studied your face since you were a baby, Diny, for nothing. Do you know, my dear,” he continued, as his child stood with her lips pressed so firmly together that they formed a thin white line, “I really think that fish have more gumption than we give them credit for. They really do get to be educated and know when they are being fished for.” “Well, what wonder that they should refuse to take a tiny patch of hair and feathers hiding a hook?” “But it’s a lovely black gnat I am trying, my dear. I couldn’t tell it in the water from the real; and there: look at that,” he cried, in a tone full of vexation, as a big trout suddenly sucked down an unfortunate fly floating close by the Major’s cunningly made lure. “I knew that fellow was there, and I hereby register a vow that I mean to have him wrapped in buttered writing-paper and grilled for my breakfast before I have done. What a—ah! that’s a good throw, right above him. That ought to tempt any natural fish. Got him!—Be ready with the net,” he cried. “Not yet,” as there was a wallow, a boil in the water, a splash, and an ejaculation as the Major’s rod, which had bent nearly double, became straight again. “Lost him, papa?”
“Lost him! Of course. My usual luck. Lightly hooked in the lip.—Eh?—No. A badly-tempered hook snapped short off. I wish the scoundrel who made it—Dinah, my dear, would you mind walking just out of hearing. There are a few good old trooper’s oaths just suitable to this occasion, and I should like to let them off.” Dinah did not stir, but a sad smile crossed her features, and she stood waiting while her father selected a fresh fly, straightened the gut, and began to fasten it to the collar of his line. “Such a pity! Just as I had hooked him too. I wonder whether he will try again. I was going to say what a deal of trouble one does take, and what an amount of time one does waste in fishing. And so you think that I need not take you up to town?” “Oh, no, no,” cried Dinah quickly. “I am quite well.” “Ahem!” “Well, nearly well again, dear. Don’t fidget about me, pray.” “Oh, no. You are of no consequence whatever, not the slightest; and I am to take no interest in you of any kind. Ah! you are a strange girl, Di, but you make my life bearable, only it seems brutally selfish to keep you down here in this wilderness.” “You know I am very happy here.” “No, I do not,” said the Major, whipping the stream rather viciously. “You have looked miserable for a month past.” “No, no, dear, you exaggerate,” said Dinah, with a smile that was piteous. “There! I am going to be as cheerful as
can be now, and you shall hear me singing about the place again.” “Hah! at last!” cried the Major, striking sharply. “Home this time, Di. I believe it’s that big trout with the distorted tail- fin. That’s right, my fine fellow; run, but I think I have you. No more lovely May-flies to be sucked down your capacious gullet. I have you, my tyrant of the waters. I’ll bring him in ten yards lower down, my dear. Mind and get your net well under him, and don’t touch him with the ring.” There followed five minutes’ playing of the gallant fish, which leaped twice out of the water in its desperate efforts to escape, and then it was gently reeled in and lifted out on the stones. “Best this season, my dear. A beauty,” said the Major, transferring the speckled beauty to his creel, and preparing for another throw. It was suppertime with the trout in the twilight, and they were feeding eagerly now, as the Major began once more—casting his line, and chatting the while to his child, who stood just beside him on his left. “They’re pretty busy bringing the machinery over to the mine, I see.” “Indeed?” “Yes; and the men told me that Mr What’s-his-name, Reed, is down again.” Dinah drew a faint breath and exhaled it in something like a sigh. “Reed—bad name for a man of trust. I say, Dinah, I don’t like that other fellow, that man Sturgess, at all.”
Dinah’s hands grasped the landing-net handle convulsively. “He is offensive. A coarse, overbearing, brutal sort of fellow. I don’t like the way he looks at me. I suppose in his eyes a man living down here in a cottage cannot be a gentleman. I shall have to give him a setting down. He is not coming to lord it over us. I saw him fishing below here the other day.” “No, no, don’t speak to him,” cried Dinah hastily. “Nonsense! I have commanded bigger and uglier fellows than he, my dear. The fellow’s insolent, and I saw him twice over clambering round the rocks and staring into the garden. I won’t have it. He shall respect my boundaries, and—Ah! good evening, Mr Reed. Down again, then! What is the last news in London?” Clive Reed had come upon them suddenly from behind one of the angles of the perpendicular rock which rose up from the narrow pathway beside the river, and was quite unnoticed until he was close at hand. Dinah turned pale as death as she uttered a low gasp, and for the moment looked as if she were about to turn and run. “Good evening, Miss Gurdon,” said Clive. He took off his hat to the Major’s daughter as he spoke; and then, as the fisherman released the hand which had been warmly grasped, the young man stood hesitating; but as Dinah made no sign, he let it fall to his side. “I have been expecting to see something of you,” continued the Major. “Have you been to the cottage?” “No,” said Clive, in a quiet, constrained tone, and to Dinah’s great relief he did not look her way, but seemed to stare
about him strangely. “I did not call. I did not expect to meet you here.” “Ah! well, never mind; we are glad to see you, but—Good heavens!—Mr Reed! You’ve been ill or something. My dear sir, have you had some accident up at the mine?” “No,” said Clive, smiling faintly. “The trouble is past. I have lost my father, Major Gurdon, since I was here. He died suddenly.” “God bless me!” cried the Major, in a tone full of sympathy, as he threw his rod aside, and laid his hand with a sympathetic movement upon the young man’s arm. “And I was thoughtlessly amusing myself here while you were in trouble. In the midst of life—dear, dear me! I am deeply grieved, sir—we are deeply grieved. Mr Reed, you have suffered much. Dinah, my child, I am sure Mr Reed will give us his company to-night.” Dinah bent her head, and, in spite of herself, gave their companion a commiserating glance, their eyes meeting, and his resting upon hers with a sad, wistful look as if he were grateful for their kindly sympathy. Then he turned to the Major. “I thank you warmly,” he said, “but not this evening. I have been down in the mine all day, and chose this path for the sake of the cool, sweet, moist air.” “The more need for a little rest and quiet communion with others, my dear young friend,” said the Major. “You will give us pain if you do refuse, Mr Reed. I too have known trouble, perhaps greater than yours. Don’t say no, sir. You will come?” Dinah stood with her lips apart, listening, as she mentally prayed that her father’s hospitality might be refused.
“You wish it?” said Clive. “My dear sir,” paid the Major, speaking rather stiffly, “I very rarely ask a visitor to my little hermitage. I have many failings, but my daughter here will endorse my words when I tell you that insincerity is not one.” “I beg your pardon, Major Gurdon,” said Clive, more warmly, “I beg Miss Gurdon’s. I am not a society man, and —and trouble and anxiety have made me rather boorish, I am afraid.” “Suppose we set aside attack and defence, my dear sir,” said the Major gravely. “I too am no society man, a mere hermit living in this desolate—no, not desolate spot. Dinah here makes my home a place of happiness and rest.” It was on Clive Reed’s lips to say coldly that he was sure that was the case, but he was in no mood for passing empty compliments, and he remained silent. “Let me be frank, Mr Reed. I look back upon the time you spent with us, sir, as a bright little spot in rather a dark existence. You impressed me favourably, sir. This is a very unconventional admission, but I am eccentric. Let me tell you openly that you impressed me very favourably, and when you do have a leisure evening, you will be conferring a kindness upon me by coming across to the cottage, where we will do our best to make your stay such as would be acceptable to a busy man—restful and calm. There, Dinah, what do you say to that for a long complimentary speech.” Dinah murmured something, but her eyes did not endorse her father’s words, for they fell, and the nerves about the corners of her lips twitched slightly as she listened to their visitor’s reply.
“This is very good and kind of you, Major Gurdon,” he said; “and I should be ungrateful if I did not accept your hospitality. Let me be frank, though, with you, sir. I came down here to try and forget my troubles in hard work. My mission is to make this mine a successful venture for the sake of those who have embarked in the scheme, and my thoughts run upon the work, and that alone. I shall prove to be a very dreary guest.” “Let me have my opinion about that,” said the Major, smiling. “You have done wisely, sir. Hard work in these solitudes will restore your tone. I came down years ago in despair, to die forgotten; but I soon found out that ‘there is a divinity which shapes our ends, rough hew them as we may.’ I was not to die, sir. Life began to have attractions once more. I found that there was something to live for besides self. Here we are, then, and, Mr Reed, you are very welcome.” He drew back for his guest to enter, and he in turn made place for Dinah, who raised her eyes to thank him in silence for his courtesy, when he saw a sudden change come over her countenance, which in an instant was full of a painful look of utter despair, as she seemed to have caught sight of something over his shoulder. The next moment she had hurried in, and Clive Reed followed, feeling a new interest in his host’s child, and at the same moment asking himself whether she were not suffering from some mental trouble, which was eating away the hopefulness of a life so young as hers. There was something very restful and calm about that evening at the cottage. Dinah hardly spoke a word, but after the pleasant meal sat engaged upon some piece of work, over which her white fingers passed hastily to and
fro, as the guest sat back in his chair and watched them, while the Major smoked his cigar at the window, and chatted at times about London and India, where he had gone through some service at the time of the Mutiny. But there were many lapses into silence, and the whole tone of the evening was grave and still, according wonderfully with Clive Reed’s state of mind, as he felt a kind of sympathy for the lady before him, and found himself working out her career, without female companionship, saving that of the stern-looking elderly servant. Dinah Gurdon, he thought, must have gone through some terrible time of anguish to wear such an aspect as he had noticed more than once, and he pitied her, as he saw the busy hands, utterly devoid of any ornament but their natural beauty of form and whiteness, still going to and fro the needlework in the light cast upon them by the shaded lamp. And then all at once it was late, and time for him to go; but he did not care to stir—all was truly calm, there was such a sweet repose about the place that life had suddenly grown dreamy, and he lay back in his chair listening to the Major, and still watching those hands that were as beautiful as— more beautiful than—Janet’s. Her face came into his mind with that, like a painful jarring discord in the midst of some soft, dreamy symphony, and he started up. “Eh? What is the matter?” cried the Major suddenly. “It is late, sir. I am keeping you up far beyond your usual time, I am sure.” “Yes, and thank you for doing so,” said the Major. “It is a pleasant change. Early to bed is good, but not too early. Why, you do not suppose, Mr Reed, that we are going to let
you tramp across the bleak mountain-side to-night, and have inquiries made for you in the morning, because you have not gone to the mine.” “But really, Major Gurdon,” protested Reed. “My dear sir, after all these years in this solitude, I know the place by heart, and there are dozens of spots—old shafts and the like—where a man may lose his life.” “But indeed—” “You are a new-comer. Yes, my dear sir, and we must take care of you. See how dark it is. Look, Dinah, my child. Go and see what the night is like.” Dinah trembled as she went to the open French window, stepped into the verandah, and came back looking ghastly, just as the dog began to bark fiercely from somewhere at the back. “Poachers after the grouse,” said the Major decisively. “I hope, Mr Reed, you will use your influence to keep your men from trespassing and going after the game—and my trout.” “Of course, sir, but—” “Well, Dinah?” said the Major, without noticing her agitated face. “It is very dark,” she said huskily. “Exactly! Too dark for you to go, my dear sir. Stay! We will have an early breakfast, and you can walk across to the mine. I will not have my peace of mind destroyed by being
summoned to sit on a jury at an inquest upon my late guest.” There was a mingling of mirth and seriousness in the Major’s words, and Reed hesitated. “Well, sir,” he said, involuntarily glancing across at Dinah, and meeting her troubled gaze. “I insist,” cried the Major. “What do you say, my dear?” Dinah started, and her voice sounded strange as she said hurriedly— “It would be very imprudent of Mr Reed to go back—on so dark a walk.” “Exactly! There, my dear sir, you are a prisoner for to- night.” “Mr Reed will excuse me now,” said Dinah quietly. “Good- night,” and she held out her hand. “Good-night,” he replied, with a grave sympathy in his tone; and he stood gazing at the door through which she had passed with the touch of her cold, moist, trembling hand still lingering in his, till the Major spoke again, after walking to the window, and shouting to the dog to lie down. “Been madness to have gone,” he said. “Why, even in broad daylight the way across the mountain needs care. My poor darling there had that nasty slip some little time ago, and she has not been the same since. You noticed, perhaps, that she looks pale and quite hysterical?” “I had noticed—I did on my first visit too—that Miss Gurdon looked very pale and ill.”
“Exactly! She gives me a great deal of concern about her health. I shall be obliged to take her up to town for good advice. But come, sit down; I will not trouble you about my cares.” “It is very late, sir.” “It is. But only a few minutes, Mr Reed. I wish to say something to you.” Reed seated himself. “Only a few words, sir, and I shall begin by asking you to pardon a much older man for his frankness.” “Pray speak, sir.” “Well, Mr Reed, I like you, and therefore I say, as a man whose life and hopes were blasted when he was young, and who would see with pain another suffer a defeat, be careful.” “Over what, sir?” said Clive sadly. “That mine. Don’t think me impertinent; but I would say to you, as a young man to whom the income you receive as engineer or manager may be of importance, don’t put too much faith in that ‘venture.’” “May I ask why, sir?” “Because mining is very treacherous, and you might be bitterly disappointed. I have seen so many failures. There, my dear sir, that is all. To put it in plain English, don’t put all your hopes or eggs into one basket. I don’t believe in that ‘White Virgin’ at all. There! forgive me:—good-night.”
“I forgive you, sir,” said Clive warmly, as he clasped the hand extended to him, “and thank you, too. Good-night.” Half-an-hour later Clive Reed was lying in the pretty little bedroom, thinking again how restful and calm it all was, and that instead of lying mentally feverish, and tossing restlessly in turn, a pleasant drowsiness was coming over him. Then he was wide awake and attent, for, from somewhere close at hand, he could hear the sound of a woman sobbing gently, evidently in her despair, and after a time it came to him that the wall on one side of his room was merely a papered over partition, and the sobs that came so faintly to his ears must be those of Dinah Gurdon, suffering from some terrible mental burden of which her father was possibly not aware. The sobbing ceased, but in spite of the peacefulness of the place, Clive Reed did not drop off to sleep, but lay thinking of the mine. Then came thoughts of Janet and of his brother —his father’s wishes—of the Doctor, and then, by a natural sequence, of the Major and his child. What was the Major? Of course his name would be in old Army Lists, but why was he down there leading so retired a life? He had hinted at some trouble. Then there was his child! Sweet, ladylike, with a charm and dignity that were strange in such a cottage as that. What was her great trouble? It was evidently mental, and her father was in ignorance, and attributed it to bodily infirmity; and that being so, she must have some secret hidden from him, possibly too from her father. So restful the minute before, now Clive Reed felt as if a hot iron had seared him, and he turned angrily on his couch.
“What is it to me?” he said to himself. “She is like the rest of them—pleasant to the eye and good for food, but once plucked, no more paradise. The old story! Pater in profound ignorance, and there is a lover. Well, I did not come here to play the spy upon Mademoiselle’s love affairs. I have had my stab, and it has been sharp. I suppose now that I ought to turn cynic and look on. No; I am too busy even for that. I have my betrothed—my ‘White Virgin’—to whom I must be faithful. Hang the girl! why couldn’t she go and cry at the bottom of the garden—top, I ought to say—or down by the river, and not where I could hear her? Mademoiselle Dinah Gurdon, you and I will never be friends, but I like the old man, and I should like to know what his secret has been. Has no faith in the mine, hasn’t he? ‘Don’t trust it, young man’—‘Don’t place all your eggs in one basket.’ I suppose he thinks I am a regular employé. Well, I look it, coming fresh out of it covered with limestone mud. Well meant, old gentleman, and I like you all the better for it. I know that you are not civil to me because I happen to be well off, and don’t ask me here because I might prove to be an eligible party for your daughter.” “Rubbish!” he muttered; “don’t be an idiot. If I thought that, I’d stay away. But it is not that. The old man is a thorough gentleman, and the girl is ladylike and nice enough.” She proved to be nice enough to make Clive Reed lie wakeful still, with his mind running upon her pale, care- marked face, and begin to wonder who the man might be who troubled her rest. “Some one at a distance,” he thought; “and the fellow doesn’t write. That’s it. Poor lassie! These women do not monopolise all the deception. It is on the other side here. Little Phyllis is left neglected in this out-of-the-way place,
quite forgotten perhaps, while Corydon has gone up to London, and plunged into all the gaieties of life—and so the world runs on.” Suddenly it struck him that there was a photograph over the mantelpiece of a fine, handsome fellow in undress uniform. He noted it when he came into the room, but thought no more of it. Now it came strongly to his mind, and suggested a fresh train of thought. That was it! The portrait of the gentleman. The father was an old soldier: the more likely for the lover to be military, and he was either away on foreign service, or leading a giddy life in some barrack town. “Why, by Jove!” thought Clive, raising himself upon his elbow. “This is a tiny cot of a place, without a spare room, I should say. The old man would be too Spartan and military to have anything but the simplest of accommodation, and the best is given to the guest. I am in my lady’s chamber. Of course. The place is feminine and full of knick-knacks. So that is the cavalier’s portrait, and I have the key to the Pandora’s box of troubles. Poor girl! But what a shame for me to turn her out. What’s that?” The endorsement of one set of Clive Reed’s musings, the overturning of others, and a glimpse into Dinah Gurdon’s secret care. For, sharp and clear, there was the rattle of a few shot against the lattice panes of the window. Then in the stillness that instantly followed there was a movement on the other side of the partition, and directly after the ringing, echoing report of a gun fired from a room on the other side of the cottage.
Chapter Sixteen. Sturgess Shows his Teeth. The loud barking of a dog followed the shot, and directly after Reed heard a sharp, light tap on a neighbouring door, and the Major’s voice— “Don’t be alarmed, my dear. I thought I heard steps in the garden; my window was open. Some prowling tramp, I expect. Lie down and go to sleep.” “Rather a military order,” thought Reed; “as if the poor girl could go to sleep under the circumstances, with her lover being shot at—Yes!” “Don’t be startled, Mr Reed,” said the Major, who had tapped at his door. “We don’t have policemen here to go their rounds. Some scoundrel was after my chickens, I expect; and the dog was asleep, so I just fired a cartridge at random as a warning to my visitor. Good-night.” “Shall I get up and go round with you?” said Reed. “My dear sir, no. He’s over the hills and far away by now. Good-night.” “Good-night, sir,” said Reed, who was half-dressed; and once more stillness reigned in the mountain solitude. “No business of mine,” he thought, as he quietly returned to bed; “I’ve enough to do to-morrow, and want rest. Chickens, eh? Poor old fellow! for chickens read little ewe lamb. Who’d have thought it of the pretty, ladylike girl? And I might have married, and eighteen or twenty years hence
have had a daughter like these two in the narrow circle of my acquaintance—a child whom I had tenderly nursed in infancy, trained as she grew up, believed in, trusted, and fancied that I shared her inmost thoughts. Then the revelation would probably have come. No; I don’t think I shall marry now; and—well, how strange! I feel as if I can sleep—that engine ought to be fixed in a week, and we’ll begin at once. I’ll have the smelting-house where I settled, and the furnaces here shall be utilised for supplying additional steam. I must send a telegram off to-morrow to hurry on that tubing. Bah! I’ll let all that go to-night, and—” “Would you like a little hot water, sir?” Clive Reed started up. “Eh? No, thanks. I don’t shave. Can I have a canful of cold, fresh from the river?” “I have brought one up, sir. Breakfast in half an hour.” Clive Reed was dressed and out in half that space of time, to find the Major busily tying up some beautiful carnations, one of which he cut and presented, dew wet, to his guest. “The most aromatic of our plants, Mr Reed,” he said. “I’m sorry I disturbed you in the night, but it was no false alarm. Look! I would not rake them out till you had seen them.” He pointed to the couple of heavy footprints in the soft soil, and to one of his carnations crushed by a boot heel. “Nothing missing,” continued the Major. “Our friend was startled; but don’t say anything about the footprints at breakfast.” “Certainly not. But are you much troubled in this way?”
“Well, no,” replied the Major, smiling grimly. “The fact is, never. I’m afraid the news of the reopening of the mine has brought some roughs down into the neighbourhood. When you get your men all at work, they’ll be too tired of a night to go wandering about.” “I am very sorry,” said Reed. “Oh, don’t say a word about it, my dear sir. I am not blaming you. I cannot expect to have Derbyshire reserved to me. There! those are smoothed out, and a man who finds that there are firearms upon premises, with people who mean to use them, will think twice before he comes again.” “Yes, of course,” said Reed, looking thoughtfully at the fine old soldierly fellow as he ceased raking his bed. “How will Mademoiselle look this morning? Paler and more startled. A deceitful little minx!” “We’ve ten minutes yet,” said the Major. “Care to walk up to the top of the garden? I can show you where my boundary runs, and yours touches it. Fair play, Mr Engineer. Keep your own side, and don’t come burrowing under me. Hang your rooting and mining! I don’t want to have my garden under- drained and my cottage come toppling about my ears.” “Don’t be alarmed, sir. I shall keep rigorously within the limits of the mapped-out estate.” “Of course you will, my dear sir. I have no fear. It is fascinating work, that mining, though. If I were a young man I might be tempted to begin myself. As you saw indoors, I do dabble a bit in mineralogy and metallurgy. Dinah, too, is quite an expert.”
“Indeed! I was noticing your collection of ores. Some of them very rich.” “Yes; bits I have chipped here and there during the long years of my stay. There we are. Your estate runs—” A shrill whistle arrested him as he stood on the top of a rugged mass of stone, high above the cottage, where luxuriant ferns clustered in every niche; and placing a little silver call which hung by his watch-chain to his lips, he blew an answer. “One is obliged to have something of this kind,” he said smilingly, “to keep our Martha from going mad. That was the breakfast-bell, or answers for it. Fine place this for your appetite, Mr Reed.” “Yes, one does get ready for one’s meals,” replied the guest, as he walked slowly back down the glen-like garden, toward the open window of the room in which they had been seated on the previous evening, and from which Dinah, simply dressed, but looking, with her large eyes and pale creamy cheeks, ten times as interesting as on the previous night, came out to meet them. “A guilty conscience needs no accuser,” thought Reed, as they drew near, but to his intense surprise she held out her hand to him with a sweet, winning frankness, and bade him good morning. Then turning to the Major, a sensation as of a sob rising in his throat affected Reed at the tender affection that seemed to exist between the pair, as Dinah raised her lips to her father’s while he embraced her. “What a brute I am!” thought Clive; and in spite of the sharp rattle of the shot seeming to ring in his ears, he told himself that he must have been wrong.
“A girl like that could not be deceitful,” he thought; and when a few minutes later they were seated at the table, and Martha came in, bearing a dish of fried ham, he looked hard at the stern robust woman, and wondered whether she was responsible for the nocturnal visitor. “Impossible!” he said to himself one moment, and the next he owned that it might be so. “Fifty if she’s a day,” he said mentally. “Well, perhaps so, and the lover has come at last.” Two hours later Clive Reed was back in the great shallow gap, where a couple of teams of horses had just dragged up heavy loads of machinery and materials, Sturgess looking morose and speaking in a surly voice, busy ordering the men about the shaft to look sharp and help to unload. The click of hammer and pick was making the place echo. Masons were busy erecting a stone building; and already the place was beginning to look business-like, and as if waking up from its long, long sleep of years. The cottage and its occupants were soon as if they were non-existent to Clive, who went at once into the temporary office which he had had erected, wrote and sent off two telegrams to the nearest town for despatch, several letters, and then, after changing his clothes, went out to descend the mine. He had accidentally arranged his time so that he met Sturgess, who had just ascended. “Ah! Sturgess,” he said, “I wanted to see you. Those rails ought to have been taken down first thing this morning, so that a line might be begun for the small trucks.” “Oh, yes, I know,” said the man roughly. The engineer looked at him wonderingly.
“Then see about it at once.” “Plenty of time, sir; plenty of time,” said Sturgess insolently. “There is not plenty of time, sir,” said Clive, in a tone of voice which rather startled the man; “and have the goodness to understand this:—My late father engaged you on the strength of your recommendations, but I am in supreme authority here, and I submit to insolence from no person in my employ.” “I didn’t mean to be insolent,” grumbled the man. “Then please understand that you were, and don’t venture upon it again, or we part at once. Now go and see that those rails are taken down directly, and that a gang of men begin to lay them at once toward the opening to the great cavern where the water flows.” “No use to lay ’em down there,” grumbled Sturgess. “You heard my orders, sir. I shall be in that direction before long.” Sturgess went out without a word, but with an ugly look upon his countenance. “All right!” he muttered. “Make much of it. People who get up very high have the farther to fall. Curse him! I’ll let him see.” “He must have been drinking,” thought Clive, as soon as he was alone. The next minute he was wrapt in the management of the mine, and giving orders to different men, ending by going to the bucket to be let down, and noting that Sturgess was
looking at him searchingly as he rose from bending over the labourers who were lifting the rails.
Welcome to our website – the perfect destination for book lovers and knowledge seekers. We believe that every book holds a new world, offering opportunities for learning, discovery, and personal growth. That’s why we are dedicated to bringing you a diverse collection of books, ranging from classic literature and specialized publications to self-development guides and children's books. More than just a book-buying platform, we strive to be a bridge connecting you with timeless cultural and intellectual values. With an elegant, user-friendly interface and a smart search system, you can quickly find the books that best suit your interests. Additionally, our special promotions and home delivery services help you save time and fully enjoy the joy of reading. Join us on a journey of knowledge exploration, passion nurturing, and personal growth every day! ebookbell.com

Clojure Programming Cookbook Makoto Hashimoto Nicolas Modrzyk

  • 1.
    Clojure Programming CookbookMakoto Hashimoto Nicolas Modrzyk download https://ebookbell.com/product/clojure-programming-cookbook- makoto-hashimoto-nicolas-modrzyk-6810064 Explore and download more ebooks at ebookbell.com
  • 2.
    Here are somerecommended products that we believe you will be interested in. You can click the link to download. Clojure Programming 1st Edition Chas Emerick Brian Carper Christophe Grand https://ebookbell.com/product/clojure-programming-1st-edition-chas- emerick-brian-carper-christophe-grand-2546580 Clojure Programming Chas Emerick Brian Carper Christophe Grand https://ebookbell.com/product/clojure-programming-chas-emerick-brian- carper-christophe-grand-53638812 Clojure Programming Chas Emerick Brian Carper Christophe Grand https://ebookbell.com/product/clojure-programming-chas-emerick-brian- carper-christophe-grand-47032898 Clojure Programming Chas Emerick Brian Carper And Christophe Grand https://ebookbell.com/product/clojure-programming-chas-emerick-brian- carper-and-christophe-grand-31644322
  • 3.
    Clojure Programming ChasEmerick Brian Carper Christophe Grand https://ebookbell.com/product/clojure-programming-chas-emerick-brian- carper-christophe-grand-43034508 Clojure Reactive Programming Leonardo Borges https://ebookbell.com/product/clojure-reactive-programming-leonardo- borges-43038448 Clojure Reactive Programming Leonardo Borges https://ebookbell.com/product/clojure-reactive-programming-leonardo- borges-5035770 Clojure Reactive Programming Design And Implement Highly Reusable Reactive Applications By Integrating Different Frameworks With Clojure Borges https://ebookbell.com/product/clojure-reactive-programming-design-and- implement-highly-reusable-reactive-applications-by-integrating- different-frameworks-with-clojure-borges-10614742 Clojure Reactive Programming Leonardo Borges https://ebookbell.com/product/clojure-reactive-programming-leonardo- borges-43192084
  • 6.
  • 7.
    Table of Contents ClojureProgramming Cookbook Credits About the Authors About the Reviewer www.PacktPub.com eBooks, discount offers, and more Why subscribe? Preface What this book covers What you need for this book Who this book is for Sections Getting ready How to do it… How it works… There's more… See also Conventions Reader feedback Customer support Downloading the example code Downloading the color images of this book Errata Piracy Questions 1. Live Programming with Clojure Introduction REPL up! Getting ready How to do it... How it works... There's more...
  • 8.
    See also Working withprimitive data types Getting ready How to do it... Using numbers Using strings and characters Using booleans and nil Using symbols and keywords How it works... There's more... Using bindings of vars, conditions, loops, and error handling Getting ready How to do it... def and let if and if-not when and when-not case and cond do and dotimes loop and recur try... catch... throw How it works... Using and defining functions Getting ready How to do it... Defining simple functions Defining variadic functions Defining multiple arity functions Defining functions that specify arguments using a keyword Defining functions with pre-condition and post-condition How it works... There's more... Using third-party libraries Getting ready How to do it... Adding the JAR file manually to your classpath Using Leiningen and a project.clj file
  • 9.
    Viewing dependencies one-off New dependenciesat runtime Using namespaces Getting ready How to do it... Creating a new namespace Inspecting namespaces Adding functions with :import and :refer Loading namespaces from files Reloading namespaces How to organize namespaces There's more... Namespace for public API tools.namespace What's next? 2. Interacting with Collections Introduction Clojure collections and their basic functions Getting ready How to do it... Lists Vectors Maps Sets How it works... Clojure collections Differences between lists and vectors Clojure is immutable There's more... Converting collections between different types Using distinct Accessing and updating elements from collections Getting ready How to do it... Accessing collections using the nth function
  • 10.
    Accessing maps orsets using get Maps, sets, and keywords are functions to access collections Accessing a collection using second, next, ffirst, and nfirst Using update to update collections How it works... There's more... Using get for vectors Using collections as keys in maps Using get-in Using assoc-in Using update-in Filtering elements from collections Getting ready How to do it... Filtering multiples of three Filtering items of a map Filtering non-nil values Removing odd values from a sequence Using keep Using keep-indexed There's more... Filter as a transducer Filtering with core.async Transforming and sorting collections Getting ready How to do it... Using built-in sort Migrating to sort-by Using sorted-set Working with sorted collection subsets Sorting Clojure maps Sorted map structure Are you sorted yet? How it works... There's more... Sorting lines of a file
  • 11.
    Merging and splittingcollections Getting ready How to do it... Using merge and merge-with for merging The zipmap merges keys and values for maps Using interleave Using split-at and split-with to split collections How it works... There's more... Using group-by to split collections Using the filter function to split collections How to become lazy Getting ready How to do it... The iterate function Realized? Random sequences with repeatedly Using the macro lazy-seq How it works... There's more... Other lazy-seq-producing functions Force evaluation with doall Lazy evaluation with files The map function and calling rest 3. Clojure Next Introduction Using destructuring techniques Getting ready How to do it... Sequential destructuring Using map destructuring How it works... There's more... Sequential destructuring for string Conditional destructing with core.match Using functional programming style
  • 12.
    Getting ready How todo it... Functions taking functions as their arguments map reduce apply Using anonymous functions Anonymous functions using fn Using function literals to define anonymous functions Functions returning functions constantly complement partial comp every-pred and some-fn How it works... Clojure functions are first-class functions Pure functions There's more... reduce and apply loop and recur Using threading macros Getting ready How to do it... Introducing the -> macro Introducing the ->> macro Introducing the cond-> and the cond->> macros Introducing some-> and some->> How it works... There's more... Introducing as-> Flambo preview Defining simple macros Getting ready How to do it... Your first macro
  • 13.
    Your second macro Howit works... There's more... Using quotes Macros everywhere Defining more advanced macros Getting ready How to do it... Tracking when code was started Logging a message with macro How it works... There's more... deftest Using protocols Getting ready How to do it... Defining a record Defining a type Defining a protocol How it works... Records and types are Java classes Differentiating between records and types There's more... Defining a mutable protocol and type Defining multimethods Getting ready How to do it... Defining a multimethod How it works... There's more... Transducers for dummies Getting ready How to do it... How it works... Composable functions Inserting elements
  • 14.
    Writing your owntransducers Short circuit There's more... Transducers with core.async Summing things up Logic programming in Clojure Getting ready Baby logic steps Getting to know the "o" vocabulary conso: check for vector association resto: check for the rest of a vector membero appendo: appending list conde Matche Beginner logic Keeping fresh Finding only one result Mature logic Range of values How to do it... Generating data Generating more data with more logic variables Using a project How it works... There's more... Validating the results of a function Working with external data 4. File Access and the Network Introduction Manipulating files and directories Getting ready How to do it... spit and slurp Reader and writer with with-open Creating a file and directory
  • 15.
    Copying a file Deletinga file and a directory Listing files and directories in a directory How it works... slurp and spit with-open macro There's more... Reading HTTP resource Examining the source code Manipulating various formats of files - XML, JSON, YAML, and EDN Getting ready How to do it... XML JSON YAML isn't a markup language MessagePack, Clojure library How it works... There's more... Extensible Data Notation Making use of Clojure HTTP client Getting ready How to do it... How it works... There's more... async HTTP and core async Using queues and topics in the RabbitMQ Getting ready Installing RabbitMQ How to do it... Producing hello world messages and consuming them Declaring the namespace and loading Langohr libraries and IP address of the Docker container Defining a producer function Defining a message handler and consumer Testing producer and consumer
  • 16.
    Using blocking consumer Howit works... Connect to broker and open channel How producer works Declaring queue Producing messages How consumer works Consumer messages Defining message handler There's more... Using fanout exchange fanout-producer fanout-consumer Running the fanout consumers Testing fanout consumers Using topic exchange Topic-publisher Topic-consumer Running the topic consumers Testing the topic consumers See also Using Kafka Getting ready Downloading Kafka 0.8.2.2 Start ZooKeeper and Kafka server Create topic Run a console consumer Using clj-kafka How to do it... Declaring the namespace and load Clojure library Producing messages Consuming a messages How it works... Producing messages Consuming messages There's more...
  • 17.
    Creating a newtopic See also Using MQTT Getting ready Installing the MQTT broker MQTT graphical client Send our first MQTT message Getting some Clojure How to do it... How it works... There's more... Streaming access to provide high performance Getting ready How to do it... Streaming out Streaming in Streaming with line-seq How it works... There's more... Using Apache Camel to connect everything Getting ready How to do it... Importing Camel classes Your first ride on Camel with Clojure Writing more Clojure idiomatic code with Camel How it works... There's more... See also 5. Working with Other Languages Introduction Calling Java methods and accessing Java objects from Clojure Getting ready How to do it... Instantiating objects Calling instance methods Calling class methods
  • 18.
    Accessing instance fields Accessingclass fields Accessing inner classes Referencing classes Using arrays How it works... Summary of how Clojure accesses Java methods and objects Clojure does not inherit Java's checked exception Summary of array accesses Print strings of Java's primitives There's more... Chained calls with the double-dot macro Using the doto macro Using reflections Extending Java superclasses and implementing Java interfaces Getting ready How to do it... Using proxy Using reify for implementing interfaces How it works... There's more... Defining anonymous classes in Clojure Using annotations Calling Clojure from Java Getting ready How to do it... Defining a simple named class using gen-class Defining a class with instance methods and constructors in Clojure Creating a JAR file callable from Java How it works... The project.clj for generating Java classes AOT compilation There's more... Defining an interface and implementing a class callable from Java
  • 19.
    Using Maven forClojure and Java projects Calling Scala from Clojure Getting ready How to do it... Using Leiningen to develop Scala and Clojure Importing Scala classes Calling instance methods Calling singleton methods Accessing tuples Accessing Scala fields How it works... There's more... Using SBT Creating an SBT-based project Writing source code ClojureCLR Getting ready Installing Visual Code Studio and creating a project Installing Mono Studio IDE Lein CLR How to do it... Calling .NET code from Clojure Starting an REPL Working with IO Parsing some XML using C# code Calling a REST API using Clojure/C# UI Prototyping Putting it all together How it works... Compiling Clojure code for .NET Adding Clojure code to a Visual Studio project Running Clojure code using Clojure.RT Using Xamarin Mono Studio There's more... ClojureScript Getting ready
  • 20.
    How to doit... Autocompiling your code Fibonacci'ed How it works... Interacting with JavaScript Using jQuery from ClojureScript Creating a ClojureScript library Using a third-party library There's more... Running in the REPL Compiling code for both Clojure and ClojureScript 6. Concurrency and Parallelism Introduction Solving concurrent problems using Clojure Getting ready How to do it... Using atoms Creating and referring atom Updating atom Using validator Using CAS operation Software Transactional Memory using ref and dosync Creating ref Updating refs using alter Using ensure Using watcher and a refined transaction code Using commute Using agents Creating agents Updating agents How it works... Summary of three reference types in Clojure Coordinated/uncoordinated Synchronous/asynchronous How STM works in Clojure Alter and commute
  • 21.
    There's more... promise anddeliver pmap, pcalls, and pvalues pcalls pvalues See also Distributed actor-based dev with Akka Getting ready How to do it... Your first okku Creating actors Dispatching messages How it works... Actor system Understanding actors There's more... Calling remote actors Request and reply See also Using Spyglass and Couchbase to share state between JVMs Getting ready Setting up dependencies in project.clj Setting up Couchbase Server as a Memcached server Using docker-compose to start Couchbase Server Creating a directory and a file for docker-compose Start Couchbase cluster Check if Docker processes are running Summary of Couchbase cluster Using Couchbase web administrator console Logging into the web console Adding nodes to the cluster Adding Cluster Defining Memcached bucket How to do it... Defining to use Spyglass library Connecting server
  • 22.
    Set values Get valuesfrom another REPL Testing time to live Disconnecting How it works... What is Memcached? Access Memcached from Telnet Couchbase Server There's more... Using get-multi Using async-get Using CAS operations See also Reactive programming with meltdown Getting ready How to do it... Defining a reactor Sending a message to a reactor Going the sync way How it works... Selectors Streams Streams and reduce Combining functions with a graph Custom streams There's more... Bridging core.async Getting ready Memories - reviewing core.async basics Pub/sub How to do it... Async socket server Async socket client Chiming There's more... Client to Python WebSockets
  • 23.
    Clojure WebSocket server OnQuasar/Pulsar Getting ready How to do it... How it works... Watching over other actors lifecycles State of an actor There's more... Blazar 7. Advanced Tips Introduction Hacking the Clojure code Getting ready How to do it... How it works... There's more... Using Reader Conditionals, compile to Clojure, and ClojureScript Getting ready How to do it... Your first Reader Conditional Using Reader Conditionals in namespaces How it works... The form of Reader Conditionals and Splice macros Macros in ClojureScript There's more... Building an application for Clojure and ClojureScript Adding a cljc file for demonstrating Quil Testing cljc code in both Clojure and ClojureScript Building and running a demo See also Real-time shared development with an REPL Getting ready How to do it... Shared REPLs Using Atom and proto-repl Using an embedded NREPL
  • 24.
    There's more... Custom REPLusing Java interop Server Client The async custom REPL server Server REPL or more on real-time work on production code Declarative data descriptions and validations with plumatic/schema Getting ready How to do it... My first schema Using schema for records and other types Defining functions with validations How it works... Performance considerations Generating test data There's more... Data coercion with prismatic/schema Using core.typed core.spec 8. Web Applications Introduction Clojure with Vaadin - easy web widgets Getting ready Project settings The Clojure/Vaadin flow How to do it... Using the Calendar widget Reacting to events Clicking a button Using and reloading namespaces Server-side push There's more... Reactive Vaadin - ideas Reactive Vaadin - CPU monitoring Reactive Vaadin - Telegram on Raspberry Pi Deployment bonus
  • 25.
    Quickly create aREST API with Liberator Getting ready How to do it... Your first Liberator Using defresource Parameterized resources Defining GET/POST/PUT/DELETE methods for REST APIs How it works... Methods and status codes of HTTP Tracing requests There's more... Persistent REST resources using clojure.java.jdbc Preparing for jdbc Our service spec Creating a product table and defining access functions Defining resources and starting a server Accessing from an HTTP client Working with Immutant - reusing infrastructure Getting ready How to do it... Simple messaging with Artemis Remote messaging Remote procedure call with queues Scheduling code execution Piping and defining data transformation pipelines Using WebSockets made easy There's more... Packaging as standalone Packaging as a deployable web archive (WAR file) Developing with om.next, the next-generation ClojureScript library Getting ready Creating a new project for om.next Updating the om version Tips for dependencies Starting figwheel How to do it...
  • 26.
    Getting started withom.next Using states How it works... React fundamentals defui reconciler Life cycle of components There's more... Task list using om.next Defining the namespace and libraries to use Defining state Defining read Defining mutate Defining UIs 9. Testing Introduction Behavior-driven development Getting ready Dependencies The first feature Designing a folder structure to organize features How to do it... Many assumptions with tables Reading assumptions from a CSV file Doing it with Excel Doing it with web APIs and MongoDB There's more... VirtualBox Freactive Flambo, or BDD meets Apache Spark EEP for BDD OpenCV Testing with random inputs and pattern-based testing Getting ready Libraries Generating random values or groups of values
  • 27.
    Random values basedon schema How to do it... Your first test.check specification Auto-running tests More specifications and generators Generators and de-structuring Herbert There's more... Benchmarking with Criterium, performance tips, and other tools Getting ready How to do it... Using Criterium How it works... Type hints Using appropriate data types Maps versus records versus types Primitive arrays Working with transient data structures Memoize functions There's more... Logging with timbre and profiling with tufte Using jvisualvm 10. Deployment and DevOps Introduction Riemann - monitoring deliverance and slacking Getting ready Installing the Riemann service Configuring the Riemann daemon The Riemann dashboard Riemann-health Just enough dashboard configuration Preparing to send events How to do it... Basic event reporting for a service Expiring events How it works...
  • 28.
    There's more... From Riemannto Slack webhooks From Slack bots to Riemann Deploying Clojure with Docker Getting ready Installing Docker on OS X or Windows Installing Docker on Debian Preparing the Clojure application Packaging the application into a JAR file Creating the Docker container How to do it... Connecting directly to a remote Docker There's more... Clojure on Amazon Web Services Getting ready Signing up on AWS Getting the access key and secret access key Setting up dependencies in your project.clj How to do it... Using EC2 Using S3 Using Amazon SQS Serverless Clojure with AWS Lambda Clojure namespace helloworld Hello World - the AWS part Hello Stream Real-world Lambdas How it works... What is Amazon EC2? Amazon S3 Buckets and keys Objects There's no more...
  • 29.
  • 30.
    Clojure Programming Cookbook Copyright© 2016 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: October 2016 Production reference: 1211016 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78588-503-7
  • 31.
  • 32.
    Credits Authors Makoto Hashimoto Nicolas Modrzyk CopyEditors Safis Editing Sameen Siddiqui Reviewers Eduard Bondarenko Dmitri Sotnikov Project Coordinator Ritika Manoj Commissioning Editor Kartikey Pandey Proofreader Safis Editing Acquisition Editor Kirk D'costa Indexer Tejal Daruwale Soni Content Development Editor Sachin Karnani Graphics Abhinash Sahu Technical Editor PranavKukreti Production Coordinator Aparna Bhagat
  • 33.
    About the Authors MakotoHashimoto is a technical enthusiast in Japan. He has been involved in a lot of projects as an IT architect and led them successfully with his technical leadership. Makoto loves programming, especially with functional programming languages. Thus, he became an enthusiast of Clojure since his first encounter with this language. Recently, he is often involved in projects of the big data domain, and he constantly thinks up new ways to use Clojure for this domain. He loves spending time with his family during weekends and apart from that he loves cooking, classical music, arts and sports. Makoto has also written two books in Japanese. You can find them at http://amzn.to/2e0jySv and http://amzn.to/2eg3gq8. To my coauthor, Nicolas, working with you has been a great honor for me. Many thanks for your valuable advices and encouragements.To my family, I would like to thank my family and friends for their constant encouragements and support. Without you, there is no way that I would have been able to complete this work. Nicolas Modrzyk has many years of experience in the field of IT and has spent many years in Asia. He loves making ideas a reality and the fact that this reality brings people from all around the planet together. He's been involved in many IT projects, helping customers reach their goal and in general trying to make IT easier to reach for everyone. Nicolas fell into the Clojure soup 5 years ago; it helped him become more focused, and stop wasting time on the things that are not worth it. Clojure is more than just a fantastic programming language; it is a life full of adventure. Hopefully, this book takes you on the road to that adventure. Nicolas has also written a book, Oishii Clojure (http://gihyo.jp/book/2013/978-4-7741-5991-1), in Japanese,
  • 34.
    with plenty ofshort Clojure recipes to enjoy the Clojure language and to make you want to try new things. Thank you, Makoto, for reaching out and making this book a fantastic adventure! Also, I'm looking forward to our next one! To my daughters, Mei and Manon, I think about you always, even during those late nights spent working on the book. To my loving family and awesome friends, for their continuous support, even in those times when I only talk about Clojure.
  • 35.
    About the Reviewer EduardBondarenko is a long-time Ruby and Clojure programmer. He got into Android development recently. He prefers concise and expressive code with some comments, and has tried many programming languages, such as Python, Erlang, Nodejs, Elm, Scala, and others. Eduard has reviewed a couple of Clojure books, and he liked all of them for their interesting and broad topics. Besides programming, he likes to spend time with his family, play soccer, and travel. I want to thank my family for supporting my desire to work on the book, and the authors for the demonstration of different and extraordinary applications of Clojure.
  • 36.
    www.PacktPub.com eBooks, discount offers,and more 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 customercare@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
  • 37.
    Preface This is abook designed to make you want to try things. It will take you back to the days when you had tons of energy and were ready to just start and make things happen. Clojure is a one of a kind programming language, where the core is very important, and you can just write efficient code, based on strong building blocks. With the upcoming release of Clojure 1.9, this language is ahead of other languages due to its simplicity and conciseness. So whether you are embarking on a weekend programming project with Raspberry Pi or getting ready to challenge the world with your new start-up, the tons of good recipes provided in this book are for you. This book can mostly be read in any order, but make sure that you go through the first few recipes to review the basics of Clojure. Make things happen and enjoy every piece of it. What this book covers Chapter 1, Live Programming with Clojure, helps you review how the Clojure basics work with different data types, how the code control flows, and also how to integrate third-party libraries. You probably know this already, but you simply cannot start a good cookbook without a strong base. Chapter 2, Interacting with Collections, covers selecting, filtering, transforming, merging, joining, and how to become lazy. Laziness is one of the greatest Clojure feature, and we want to make sure that you will always be lazy enough. Chapter 3, Clojure Next, introduces you to macros, advanced macros, transducers (what transducers are, anyway), and logic programming. It
  • 38.
    covers preprocessing andpostprocessing of Clojure data as code features. Chapter 4, File Access and the Network, covers StreamingQueues and real-time networking, which gives you the power to think about distributed systems and how to connect your IoT devices. It also covers files and how to manipulate files to help you with lightweight processing for interconnections. Chapter 5, Working with Other Languages, introduces you to the basic Clojure tooling that allows you to easily integrate code written in other languages, such as Java, Scala, and .NET, all the way to Clojure on the JavaScript runtime, ClojureScript. Chapter 6, Concurrency and Parallelism, helps you learn multiple ways of splitting jobs among Clojure processes, interacting with Scala-like actors, and to also sharing states between different instances. Of course, this chapter covers the simplest way of writing a parallel code in Clojure, core.async. Chapter 7, Advanced Tips, helps you if you want to know how to perform not only pair programming but also shared real-time pair programming. You will also see how to hack the Clojure source code yourself. Chapter 8, Web Applications, takes you through web applications, web services, or API endpoints or whatever you call them. You also learn how to use nice-looking widgets with Vaadin, how to write rest-like APIs with Liberator, and use Immutant, a set of server-side services at the finger of your Clojure code. Chapter 9, Testing, not only helps you with validating your code but also with using random pattern testing for the cases you had not thought about. This chapter also introduces behavior-driven development in Clojure with some OpenCV validation, and finally, explains how to benchmark the speed of your code.
  • 39.
    Chapter 10, Deploymentand DevOps, covers dockerizing your Clojure code, making it run locally as it would in the Cloud, putting real-time monitoring in place for your critical services, and finally, your favorite Amazon tricks are also covered here.
  • 40.
    What you needfor this book You need a bit of time, a computer, and a text editor. That's all this book requires. Of course, previous functional programming experience is a big plus, but having motivation and energy is pretty much all you need.
  • 41.
    Who this bookis for This book is for people who want to make things happen. Follow along the lines of the zillions of code samples included in this book, and go ahead from there. Each example should make you want to try things around, and bring up some new ideas. This book should start by being just a cookbook, but by the end, will become your cookbook.
  • 42.
    Sections In this book,you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also). To give clear instructions on how to complete a recipe, we use these sections as follows: Getting ready This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe. How to do it… This section contains the steps required to follow the recipe. How it works… This section usually consists of a detailed explanation of what happened in the previous section. There's more… This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe. See also This section provides helpful links to other useful information for the recipe.
  • 43.
    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: "However, declaring libraries in project.clj is much simpler than doing it in the pom.xml file of Maven." A block of code is set as follows: String str = "Hello ".concat("world !"); Any command-line input or output is written as follows: $ mv lein ~/bin 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: "Go to the Data Buckets tab and click on the Create New Data Bucket option." Note Warnings or important notes appear in a box like this. Tip Tips and tricks appear like this.
  • 44.
    Reader feedback Feedback fromour 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 .
  • 45.
    Customer support Now thatyou are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase. Downloading the example code You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and 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. You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account. 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
  • 46.
    https://github.com/PacktPublishing/Clojure-Programming-Cookbook. We also haveother code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. 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/downloads/ClojureProgrammingC 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/content/support and 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
  • 47.
    works in anyform 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.
  • 48.
    Chapter 1. LiveProgramming with Clojure In this chapter, we will cover the following topics: REPL up! Working with primitive data types Using bindings of vars, conditions, loops, and error handling Using and defining functions Using third-party libraries Using namespaces Introduction Clojure is a blend of Lisp and Java. Clojure allows you to solve what you want quickly and keeps code simple. Once you learn Clojure, it's great fun to use it! Clojure provides the following fantastic features: Clojure is a dialect of Lisp and supports the functional programing style It runs on Java Virtual Machine (JVM) and can use Java's assets seamlessly It also supports immutability and concurrent programming In this chapter, we will review how to set up a Clojure REPL environment and Clojures' basic structure, including primitive data types, programming flow controls, and functions. Then we will go over how to use third-party libraries and namespaces. Let's take you to Clojure's fantastic world; we'll begin with REPL up!
  • 49.
    REPL up! REPL isthe interpreter of Clojure, and it is an acronym of Read Evaluate Print Loop. Unlike other interpreter languages, such as Python or Ruby, Clojure REPL automatically compiles into Java's byte code after the reading expression. Then, REPL evaluates the expression and returns the result of the expression. This dynamic compilation feature of REPL makes Clojure code execution as fast as executing pre- compiled code. Getting ready Before you set up your Clojure environment, the Java Development Kit (JDK) is necessary. The JDK version should be 1.6 or later. Throughout the book, we will use JDK 1.8 to develop and test the code. This is how the command-line result will look, once you type java - version: How to do it... Leiningen is a standard build tool for Clojure. It simplifies the Clojure development, including setting up your project, compiling and testing code, and creating libraries for deployment. It's easy to set up a Clojure environment using Leiningen. There are only
  • 50.
    a few stepsbefore you can enjoy Clojure in REPL! Here are the steps we need to perform to run Clojure REPL: 1. Download and set up Leiningen from http://leiningen.org/. 2. Download the lein script (or on Windows, lein.bat). 3. Place it on your $PATH where your shell can find it (for example, ~/bin): $ mv lein ~/bin 4. Set it to be executable: $ chmod a+x ~/bin/lein 5. Run lein, and it will download the self-install package:
  • 51.
    6. Create anew project and go there. Using Leiningen, you can create a project from a project template. This example creates a project called living-clojure: $ lein new living-clojure 7. Run REPL and put Clojure code into it:
  • 52.
    How it works... Hereis a very simple code to demonstrate how REPL works. This code simply loops forever with read, eval, and println functions: user=> (defn simple-repl [] #_=> (try #_=> (while true #_=> (println (eval (read))) #_=> ) #_=> (catch Exception e (println "exited..")) #_=> ) #_=> ) #'user/simple-repl user=> (simple-repl) (+ 1 1) 2 (defn hello [s] (println "Hello world " s)) #'user/hello (hello "Makoto") Hello world Makoto nil exited.. nil user=>
  • 53.
    You can exitsimple-repl by entering ^D (Ctrl + D). There's more... Leiningen is a very powerful tool for Clojure developers. The lein new living-clojure command generates the following directory structure: Let's pick up project.clj, which defines the project: (defproject living-clojure "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.8.0"]]) In project.clj, the :dependencies section declares the libraries used by your project. Leiningen internally uses Maven to solve the dependencies of libraries.
  • 54.
    However, declaring librariesin project.clj is much simpler than doing it in the pom.xml file of Maven. To use other libraries for your project, add them to the dependency section. We will review how to do this in a later recipe. In the preceding project.clj file, the Clojure library named org.clojure/clojure is declared and automatically downloads in the maven directory. This is the reason why you don't need to download and set up the Clojure library explicitly. Without Leiningen, you have to do it in a more native way. Here are the steps: 1. Download clojure-1.8.0.jar. 2. Download clojure-1.8.0.jar using wget: $ wget http://repo1.maven.org/maven2/org/clojure/clojure/1.8.0/ clojure-1.8.0.jar 3. Run Clojure and test the Clojure code: $ java -jar clojure-1.8.0.jar Clojure 1.8.0 user=> (+ 1 1) 2 REPL supports the command-line editing feature, like Linux bash shell does, but the preceding way does not. Another difference is that REPL solves library dependency problems in project.clj, but using the native
  • 55.
    Exploring the Varietyof Random Documents with Different Content
  • 56.
    Chapter Fourteen. At Dinner. “Holdyour tongue, boy! Don’t contradict me. You’re not to think because your father is dead that you are going to do just as you like. Try some more of that claret; it’s very good. There were only fifty dozen of it, and your father and I shared the lot. I suppose you’ve got some of it left in the cellar—your cellar. Dear, dear! poor old Grantham, what a change! There, fill up your glass. That won’t hurt you. I say it as a medical man. That’s wine that maketh glad the heart of man; and one needs it now, for homes desolate enough. The miserable jade!” “It was not her fault,” said Clive sadly. “What! I say it was her fault, so don’t you defend her. Confound you, sir, I know you’ve grown into a big, ugly, consequential fellow; but recollect this, sir, I consider I take your father’s place now he’s gone. I’m the first man who ever held you in his hands. Didn’t I vaccinate you, and bring you through half-a-dozen miserable little baby disorders? You are Clive Reed, mine-owner and rich man to the world; but you are only the squalling brat and scrubby boy, sir, to me.” The Doctor tossed off a glass of his rich claret, and then swung himself round in his chair. “Don’t take any notice of what I say, boy. I’m not myself.” Clive rose from his chair and went and laid his hand upon the Doctor’s shoulder, to have it seized and held.
  • 57.
    “My dear oldfriend!” he said, in a low voice. “Thank you, my boy, thank you. God bless you! I seem to have no one but you—now she’s gone. Clive, my lad, I’ll tell you. I came back here after the funeral and went into the drawing-room, and I turned her picture with its face to the wall, after I’d cursed her like old fathers used to do in the plays when I was a boy. I said I cast her off for ever; and then I sat down in my chair, and did what I hadn’t done since her mother, my poor dear wife, died. I cried, boy, like a little child. For it seemed as if she was dead too—dead and gone—and I had suddenly turned into a disappointed, lonely old man.” “And then you turned the picture back, and owned to yourself that you loved her very dearly still, as I do, sir. For we cannot tear our affections up by the roots like that.” “I did, Clive, my boy, I did; for you are right. I know too now that it’s my own fault, for I spoiled and indulged her. She was left to me almost a child, motherless, and I began to treat her at once as a woman. I let her have her own way in everything, and she grew up pettish and jealous, and ready to resent every check. Times and times, when I’ve offended her, has she gone right off on a visit, just to annoy me, and show how independent she was. But there! it’s all over now.” “Yes,” said Clive softly, “it’s all over now.” “And how I used to reckon upon it all!” continued the Doctor. “You two married, and the little children springing up—hers and yours, boy, to make my old life young again. But it’s all over. I won’t say I’ll never see her again, but I’ve done with her; and as for that miserable, cunning, unprincipled scoundrel, how long will it be before he’s laid
  • 58.
    up with D.T.,or something worse—if there is anything worse? I’ll go and attend him gratis, and pay for his funeral afterwards with pleasure.” “No, no, not you,” said Clive quietly. “I will, sir; I shall consider it a duty to that poor girl to make her a widow as soon as possible, so that she may live in peace and repent.” Clive shook his head. “The man she loves,” he said softly. “She doesn’t; she can’t love such a scoundrel. The brainless, little, thoughtless idiot! She believed all that of you directly, and ran off to marry the blackguard who has been trying for weeks to undermine you, so as to get my money. Why, I find he has been constantly coming here to see her, and she in her vanity played with him—a little coquette—played with the confounded serpent, till he wound round and stung her.” Clive hung his head. “And all the time you and I would have been ready to knock the man down who had dared to suggest that she was trifling with you. Bah! they’re a poor, weak, pitiful lot, the women, Clive. I’ve doctored enough of them to know all their little weaknesses, my lad. A poor, pitiful lot!” “Do you think so?” said Clive quietly. “Well, some of them. But, by jingo, boy, what a punishment for the designing scoundrel. He had heard poor old Grantham let drop that he had put Janet—I mean that girl— down for a big sum, and he played for it—gambled. He
  • 59.
    meant that. Byjingo! his face when he found he had lost! I’m going to let you know, too, what I have done.” “What have you done?” said Clive, rather anxiously. “Made a new will, sir, and had the old one burned before my eyes. I’ve gone on saving for that girl, and the money’s hers, and she shall have it when I die; but he shan’t. I went to old Belton, told him what I wanted, and he went into it con amore, for he dislikes Master Jessop consumedly. He says it’s a natural reversion—the harking back to a bad strain that once got into the Reed blood.” “But what did you do?” said Clive. “Do, boy! tied the money up as tight as the law can tie it. My little bit is to be in the hands of trustees, and she will get the dividends, but she cannot sell out and give the money to your blackguard of a brother; and in a very short time he’ll know it, begin to ill-use her, and go on till she shows that she has some spirit, and then she’ll turn upon him, there’ll be a row, and she’ll come home.” Clive sat frowning. “It will be my revenge upon the scoundrel. I say, by the way, that little parlour-maid, Lyddy, what about her?” “I know nothing,” said Clive sadly. “The scoundrel has spirited her away somewhere, I suppose. Ah! well, they’ll make him suffer for it in the long- run, and you and I will have a pretty revenge. There now, not another word about either of them. You told me you were going down to Derbyshire again.” “Yes, to-morrow.”
  • 60.
    “That’s right! Goand work, my lad. You won’t do it merely for the money, but to carry out my poor old friend’s wishes. You’ve got to make that mine a very big success. I’ve put a lot in it, my boy, so you mustn’t let me lose. I mean to take up what Byron calls a good old gentlemanly vice—avarice. Don’t be down-hearted, boy. Have another glass of claret, and we’ll drink to your success. One of these days I shall come and drink your bride’s health. Some true, sweet girl, whom I can call daughter. Ah! you shake your head now, because you have just been to the funeral of your coming hopes. But wait a bit, my boy. The world turns round, and after the winter the summer comes again.” Clive Reed sighed, and at that hour, sick and sore at heart, and despairing, as much on account of the woman he loved as upon his own, everything ahead looked black but the prospect of his late father’s venture, and over this he now set himself to work; not to make money, for he had plenty, but to dull the gnawing pain always busy at his heart.
  • 61.
    Chapter Fifteen. The Undercurrent. “Hah!I nearly had you that time, my fine fellow,” said Major Gurdon, as he stood deep in the shade, where twilight was falling fast, and ever and anon he deftly threw a fly with his lissome rod right across to the edge of the black water, where the deep suddenly grew shallow, and a sharp rippling was made by the swiftly flowing stream. “Feel it chilly, my dear?” he said, as he made the brass winch chirrup as he drew out more line. “No, dear,” said Dinah, with her pale, troubled face lighting up, as she stood there holding a landing-net. “It is very beautiful and cool and pleasant now.” “Ah! that sounds better,” said the Major, as he made his fine line whish through the air and sent the fly far away down- stream. “You have been fidgeting me, my dear.” “I, papa?” said the girl hurriedly. “Yes. You haven’t seemed the same since you had that fall.” “Oh, it was nothing much, dear.” “But it was a good deal to make you look so white and upset ever since.—Missed him!—Do you know, my dear,” continued the Major, making another throw, “I lay awake half last night thinking that I ought to take you up to London to see some clever physician.”
  • 62.
    “Oh, no, no,no,” said the girl hurriedly. “You shouldn’t fidget about that. I am better. I am, indeed.” “Then impossibilities have come to pass, and your little face is deceitful.” “You take too much notice of things, dear,” said Dinah, shrinking a little behind her father, so as to hide the fresh shade of trouble in her countenance. “Oh no, I don’t,” said the Major, as he threw his fly again. “I have not studied your face since you were a baby, Diny, for nothing. Do you know, my dear,” he continued, as his child stood with her lips pressed so firmly together that they formed a thin white line, “I really think that fish have more gumption than we give them credit for. They really do get to be educated and know when they are being fished for.” “Well, what wonder that they should refuse to take a tiny patch of hair and feathers hiding a hook?” “But it’s a lovely black gnat I am trying, my dear. I couldn’t tell it in the water from the real; and there: look at that,” he cried, in a tone full of vexation, as a big trout suddenly sucked down an unfortunate fly floating close by the Major’s cunningly made lure. “I knew that fellow was there, and I hereby register a vow that I mean to have him wrapped in buttered writing-paper and grilled for my breakfast before I have done. What a—ah! that’s a good throw, right above him. That ought to tempt any natural fish. Got him!—Be ready with the net,” he cried. “Not yet,” as there was a wallow, a boil in the water, a splash, and an ejaculation as the Major’s rod, which had bent nearly double, became straight again. “Lost him, papa?”
  • 63.
    “Lost him! Ofcourse. My usual luck. Lightly hooked in the lip.—Eh?—No. A badly-tempered hook snapped short off. I wish the scoundrel who made it—Dinah, my dear, would you mind walking just out of hearing. There are a few good old trooper’s oaths just suitable to this occasion, and I should like to let them off.” Dinah did not stir, but a sad smile crossed her features, and she stood waiting while her father selected a fresh fly, straightened the gut, and began to fasten it to the collar of his line. “Such a pity! Just as I had hooked him too. I wonder whether he will try again. I was going to say what a deal of trouble one does take, and what an amount of time one does waste in fishing. And so you think that I need not take you up to town?” “Oh, no, no,” cried Dinah quickly. “I am quite well.” “Ahem!” “Well, nearly well again, dear. Don’t fidget about me, pray.” “Oh, no. You are of no consequence whatever, not the slightest; and I am to take no interest in you of any kind. Ah! you are a strange girl, Di, but you make my life bearable, only it seems brutally selfish to keep you down here in this wilderness.” “You know I am very happy here.” “No, I do not,” said the Major, whipping the stream rather viciously. “You have looked miserable for a month past.” “No, no, dear, you exaggerate,” said Dinah, with a smile that was piteous. “There! I am going to be as cheerful as
  • 64.
    can be now,and you shall hear me singing about the place again.” “Hah! at last!” cried the Major, striking sharply. “Home this time, Di. I believe it’s that big trout with the distorted tail- fin. That’s right, my fine fellow; run, but I think I have you. No more lovely May-flies to be sucked down your capacious gullet. I have you, my tyrant of the waters. I’ll bring him in ten yards lower down, my dear. Mind and get your net well under him, and don’t touch him with the ring.” There followed five minutes’ playing of the gallant fish, which leaped twice out of the water in its desperate efforts to escape, and then it was gently reeled in and lifted out on the stones. “Best this season, my dear. A beauty,” said the Major, transferring the speckled beauty to his creel, and preparing for another throw. It was suppertime with the trout in the twilight, and they were feeding eagerly now, as the Major began once more—casting his line, and chatting the while to his child, who stood just beside him on his left. “They’re pretty busy bringing the machinery over to the mine, I see.” “Indeed?” “Yes; and the men told me that Mr What’s-his-name, Reed, is down again.” Dinah drew a faint breath and exhaled it in something like a sigh. “Reed—bad name for a man of trust. I say, Dinah, I don’t like that other fellow, that man Sturgess, at all.”
  • 65.
    Dinah’s hands graspedthe landing-net handle convulsively. “He is offensive. A coarse, overbearing, brutal sort of fellow. I don’t like the way he looks at me. I suppose in his eyes a man living down here in a cottage cannot be a gentleman. I shall have to give him a setting down. He is not coming to lord it over us. I saw him fishing below here the other day.” “No, no, don’t speak to him,” cried Dinah hastily. “Nonsense! I have commanded bigger and uglier fellows than he, my dear. The fellow’s insolent, and I saw him twice over clambering round the rocks and staring into the garden. I won’t have it. He shall respect my boundaries, and—Ah! good evening, Mr Reed. Down again, then! What is the last news in London?” Clive Reed had come upon them suddenly from behind one of the angles of the perpendicular rock which rose up from the narrow pathway beside the river, and was quite unnoticed until he was close at hand. Dinah turned pale as death as she uttered a low gasp, and for the moment looked as if she were about to turn and run. “Good evening, Miss Gurdon,” said Clive. He took off his hat to the Major’s daughter as he spoke; and then, as the fisherman released the hand which had been warmly grasped, the young man stood hesitating; but as Dinah made no sign, he let it fall to his side. “I have been expecting to see something of you,” continued the Major. “Have you been to the cottage?” “No,” said Clive, in a quiet, constrained tone, and to Dinah’s great relief he did not look her way, but seemed to stare
  • 66.
    about him strangely.“I did not call. I did not expect to meet you here.” “Ah! well, never mind; we are glad to see you, but—Good heavens!—Mr Reed! You’ve been ill or something. My dear sir, have you had some accident up at the mine?” “No,” said Clive, smiling faintly. “The trouble is past. I have lost my father, Major Gurdon, since I was here. He died suddenly.” “God bless me!” cried the Major, in a tone full of sympathy, as he threw his rod aside, and laid his hand with a sympathetic movement upon the young man’s arm. “And I was thoughtlessly amusing myself here while you were in trouble. In the midst of life—dear, dear me! I am deeply grieved, sir—we are deeply grieved. Mr Reed, you have suffered much. Dinah, my child, I am sure Mr Reed will give us his company to-night.” Dinah bent her head, and, in spite of herself, gave their companion a commiserating glance, their eyes meeting, and his resting upon hers with a sad, wistful look as if he were grateful for their kindly sympathy. Then he turned to the Major. “I thank you warmly,” he said, “but not this evening. I have been down in the mine all day, and chose this path for the sake of the cool, sweet, moist air.” “The more need for a little rest and quiet communion with others, my dear young friend,” said the Major. “You will give us pain if you do refuse, Mr Reed. I too have known trouble, perhaps greater than yours. Don’t say no, sir. You will come?” Dinah stood with her lips apart, listening, as she mentally prayed that her father’s hospitality might be refused.
  • 67.
    “You wish it?”said Clive. “My dear sir,” paid the Major, speaking rather stiffly, “I very rarely ask a visitor to my little hermitage. I have many failings, but my daughter here will endorse my words when I tell you that insincerity is not one.” “I beg your pardon, Major Gurdon,” said Clive, more warmly, “I beg Miss Gurdon’s. I am not a society man, and —and trouble and anxiety have made me rather boorish, I am afraid.” “Suppose we set aside attack and defence, my dear sir,” said the Major gravely. “I too am no society man, a mere hermit living in this desolate—no, not desolate spot. Dinah here makes my home a place of happiness and rest.” It was on Clive Reed’s lips to say coldly that he was sure that was the case, but he was in no mood for passing empty compliments, and he remained silent. “Let me be frank, Mr Reed. I look back upon the time you spent with us, sir, as a bright little spot in rather a dark existence. You impressed me favourably, sir. This is a very unconventional admission, but I am eccentric. Let me tell you openly that you impressed me very favourably, and when you do have a leisure evening, you will be conferring a kindness upon me by coming across to the cottage, where we will do our best to make your stay such as would be acceptable to a busy man—restful and calm. There, Dinah, what do you say to that for a long complimentary speech.” Dinah murmured something, but her eyes did not endorse her father’s words, for they fell, and the nerves about the corners of her lips twitched slightly as she listened to their visitor’s reply.
  • 68.
    “This is verygood and kind of you, Major Gurdon,” he said; “and I should be ungrateful if I did not accept your hospitality. Let me be frank, though, with you, sir. I came down here to try and forget my troubles in hard work. My mission is to make this mine a successful venture for the sake of those who have embarked in the scheme, and my thoughts run upon the work, and that alone. I shall prove to be a very dreary guest.” “Let me have my opinion about that,” said the Major, smiling. “You have done wisely, sir. Hard work in these solitudes will restore your tone. I came down years ago in despair, to die forgotten; but I soon found out that ‘there is a divinity which shapes our ends, rough hew them as we may.’ I was not to die, sir. Life began to have attractions once more. I found that there was something to live for besides self. Here we are, then, and, Mr Reed, you are very welcome.” He drew back for his guest to enter, and he in turn made place for Dinah, who raised her eyes to thank him in silence for his courtesy, when he saw a sudden change come over her countenance, which in an instant was full of a painful look of utter despair, as she seemed to have caught sight of something over his shoulder. The next moment she had hurried in, and Clive Reed followed, feeling a new interest in his host’s child, and at the same moment asking himself whether she were not suffering from some mental trouble, which was eating away the hopefulness of a life so young as hers. There was something very restful and calm about that evening at the cottage. Dinah hardly spoke a word, but after the pleasant meal sat engaged upon some piece of work, over which her white fingers passed hastily to and
  • 69.
    fro, as theguest sat back in his chair and watched them, while the Major smoked his cigar at the window, and chatted at times about London and India, where he had gone through some service at the time of the Mutiny. But there were many lapses into silence, and the whole tone of the evening was grave and still, according wonderfully with Clive Reed’s state of mind, as he felt a kind of sympathy for the lady before him, and found himself working out her career, without female companionship, saving that of the stern-looking elderly servant. Dinah Gurdon, he thought, must have gone through some terrible time of anguish to wear such an aspect as he had noticed more than once, and he pitied her, as he saw the busy hands, utterly devoid of any ornament but their natural beauty of form and whiteness, still going to and fro the needlework in the light cast upon them by the shaded lamp. And then all at once it was late, and time for him to go; but he did not care to stir—all was truly calm, there was such a sweet repose about the place that life had suddenly grown dreamy, and he lay back in his chair listening to the Major, and still watching those hands that were as beautiful as— more beautiful than—Janet’s. Her face came into his mind with that, like a painful jarring discord in the midst of some soft, dreamy symphony, and he started up. “Eh? What is the matter?” cried the Major suddenly. “It is late, sir. I am keeping you up far beyond your usual time, I am sure.” “Yes, and thank you for doing so,” said the Major. “It is a pleasant change. Early to bed is good, but not too early. Why, you do not suppose, Mr Reed, that we are going to let
  • 70.
    you tramp acrossthe bleak mountain-side to-night, and have inquiries made for you in the morning, because you have not gone to the mine.” “But really, Major Gurdon,” protested Reed. “My dear sir, after all these years in this solitude, I know the place by heart, and there are dozens of spots—old shafts and the like—where a man may lose his life.” “But indeed—” “You are a new-comer. Yes, my dear sir, and we must take care of you. See how dark it is. Look, Dinah, my child. Go and see what the night is like.” Dinah trembled as she went to the open French window, stepped into the verandah, and came back looking ghastly, just as the dog began to bark fiercely from somewhere at the back. “Poachers after the grouse,” said the Major decisively. “I hope, Mr Reed, you will use your influence to keep your men from trespassing and going after the game—and my trout.” “Of course, sir, but—” “Well, Dinah?” said the Major, without noticing her agitated face. “It is very dark,” she said huskily. “Exactly! Too dark for you to go, my dear sir. Stay! We will have an early breakfast, and you can walk across to the mine. I will not have my peace of mind destroyed by being
  • 71.
    summoned to siton a jury at an inquest upon my late guest.” There was a mingling of mirth and seriousness in the Major’s words, and Reed hesitated. “Well, sir,” he said, involuntarily glancing across at Dinah, and meeting her troubled gaze. “I insist,” cried the Major. “What do you say, my dear?” Dinah started, and her voice sounded strange as she said hurriedly— “It would be very imprudent of Mr Reed to go back—on so dark a walk.” “Exactly! There, my dear sir, you are a prisoner for to- night.” “Mr Reed will excuse me now,” said Dinah quietly. “Good- night,” and she held out her hand. “Good-night,” he replied, with a grave sympathy in his tone; and he stood gazing at the door through which she had passed with the touch of her cold, moist, trembling hand still lingering in his, till the Major spoke again, after walking to the window, and shouting to the dog to lie down. “Been madness to have gone,” he said. “Why, even in broad daylight the way across the mountain needs care. My poor darling there had that nasty slip some little time ago, and she has not been the same since. You noticed, perhaps, that she looks pale and quite hysterical?” “I had noticed—I did on my first visit too—that Miss Gurdon looked very pale and ill.”
  • 72.
    “Exactly! She givesme a great deal of concern about her health. I shall be obliged to take her up to town for good advice. But come, sit down; I will not trouble you about my cares.” “It is very late, sir.” “It is. But only a few minutes, Mr Reed. I wish to say something to you.” Reed seated himself. “Only a few words, sir, and I shall begin by asking you to pardon a much older man for his frankness.” “Pray speak, sir.” “Well, Mr Reed, I like you, and therefore I say, as a man whose life and hopes were blasted when he was young, and who would see with pain another suffer a defeat, be careful.” “Over what, sir?” said Clive sadly. “That mine. Don’t think me impertinent; but I would say to you, as a young man to whom the income you receive as engineer or manager may be of importance, don’t put too much faith in that ‘venture.’” “May I ask why, sir?” “Because mining is very treacherous, and you might be bitterly disappointed. I have seen so many failures. There, my dear sir, that is all. To put it in plain English, don’t put all your hopes or eggs into one basket. I don’t believe in that ‘White Virgin’ at all. There! forgive me:—good-night.”
  • 73.
    “I forgive you,sir,” said Clive warmly, as he clasped the hand extended to him, “and thank you, too. Good-night.” Half-an-hour later Clive Reed was lying in the pretty little bedroom, thinking again how restful and calm it all was, and that instead of lying mentally feverish, and tossing restlessly in turn, a pleasant drowsiness was coming over him. Then he was wide awake and attent, for, from somewhere close at hand, he could hear the sound of a woman sobbing gently, evidently in her despair, and after a time it came to him that the wall on one side of his room was merely a papered over partition, and the sobs that came so faintly to his ears must be those of Dinah Gurdon, suffering from some terrible mental burden of which her father was possibly not aware. The sobbing ceased, but in spite of the peacefulness of the place, Clive Reed did not drop off to sleep, but lay thinking of the mine. Then came thoughts of Janet and of his brother —his father’s wishes—of the Doctor, and then, by a natural sequence, of the Major and his child. What was the Major? Of course his name would be in old Army Lists, but why was he down there leading so retired a life? He had hinted at some trouble. Then there was his child! Sweet, ladylike, with a charm and dignity that were strange in such a cottage as that. What was her great trouble? It was evidently mental, and her father was in ignorance, and attributed it to bodily infirmity; and that being so, she must have some secret hidden from him, possibly too from her father. So restful the minute before, now Clive Reed felt as if a hot iron had seared him, and he turned angrily on his couch.
  • 74.
    “What is itto me?” he said to himself. “She is like the rest of them—pleasant to the eye and good for food, but once plucked, no more paradise. The old story! Pater in profound ignorance, and there is a lover. Well, I did not come here to play the spy upon Mademoiselle’s love affairs. I have had my stab, and it has been sharp. I suppose now that I ought to turn cynic and look on. No; I am too busy even for that. I have my betrothed—my ‘White Virgin’—to whom I must be faithful. Hang the girl! why couldn’t she go and cry at the bottom of the garden—top, I ought to say—or down by the river, and not where I could hear her? Mademoiselle Dinah Gurdon, you and I will never be friends, but I like the old man, and I should like to know what his secret has been. Has no faith in the mine, hasn’t he? ‘Don’t trust it, young man’—‘Don’t place all your eggs in one basket.’ I suppose he thinks I am a regular employé. Well, I look it, coming fresh out of it covered with limestone mud. Well meant, old gentleman, and I like you all the better for it. I know that you are not civil to me because I happen to be well off, and don’t ask me here because I might prove to be an eligible party for your daughter.” “Rubbish!” he muttered; “don’t be an idiot. If I thought that, I’d stay away. But it is not that. The old man is a thorough gentleman, and the girl is ladylike and nice enough.” She proved to be nice enough to make Clive Reed lie wakeful still, with his mind running upon her pale, care- marked face, and begin to wonder who the man might be who troubled her rest. “Some one at a distance,” he thought; “and the fellow doesn’t write. That’s it. Poor lassie! These women do not monopolise all the deception. It is on the other side here. Little Phyllis is left neglected in this out-of-the-way place,
  • 75.
    quite forgotten perhaps,while Corydon has gone up to London, and plunged into all the gaieties of life—and so the world runs on.” Suddenly it struck him that there was a photograph over the mantelpiece of a fine, handsome fellow in undress uniform. He noted it when he came into the room, but thought no more of it. Now it came strongly to his mind, and suggested a fresh train of thought. That was it! The portrait of the gentleman. The father was an old soldier: the more likely for the lover to be military, and he was either away on foreign service, or leading a giddy life in some barrack town. “Why, by Jove!” thought Clive, raising himself upon his elbow. “This is a tiny cot of a place, without a spare room, I should say. The old man would be too Spartan and military to have anything but the simplest of accommodation, and the best is given to the guest. I am in my lady’s chamber. Of course. The place is feminine and full of knick-knacks. So that is the cavalier’s portrait, and I have the key to the Pandora’s box of troubles. Poor girl! But what a shame for me to turn her out. What’s that?” The endorsement of one set of Clive Reed’s musings, the overturning of others, and a glimpse into Dinah Gurdon’s secret care. For, sharp and clear, there was the rattle of a few shot against the lattice panes of the window. Then in the stillness that instantly followed there was a movement on the other side of the partition, and directly after the ringing, echoing report of a gun fired from a room on the other side of the cottage.
  • 76.
    Chapter Sixteen. Sturgess Showshis Teeth. The loud barking of a dog followed the shot, and directly after Reed heard a sharp, light tap on a neighbouring door, and the Major’s voice— “Don’t be alarmed, my dear. I thought I heard steps in the garden; my window was open. Some prowling tramp, I expect. Lie down and go to sleep.” “Rather a military order,” thought Reed; “as if the poor girl could go to sleep under the circumstances, with her lover being shot at—Yes!” “Don’t be startled, Mr Reed,” said the Major, who had tapped at his door. “We don’t have policemen here to go their rounds. Some scoundrel was after my chickens, I expect; and the dog was asleep, so I just fired a cartridge at random as a warning to my visitor. Good-night.” “Shall I get up and go round with you?” said Reed. “My dear sir, no. He’s over the hills and far away by now. Good-night.” “Good-night, sir,” said Reed, who was half-dressed; and once more stillness reigned in the mountain solitude. “No business of mine,” he thought, as he quietly returned to bed; “I’ve enough to do to-morrow, and want rest. Chickens, eh? Poor old fellow! for chickens read little ewe lamb. Who’d have thought it of the pretty, ladylike girl? And I might have married, and eighteen or twenty years hence
  • 77.
    have had adaughter like these two in the narrow circle of my acquaintance—a child whom I had tenderly nursed in infancy, trained as she grew up, believed in, trusted, and fancied that I shared her inmost thoughts. Then the revelation would probably have come. No; I don’t think I shall marry now; and—well, how strange! I feel as if I can sleep—that engine ought to be fixed in a week, and we’ll begin at once. I’ll have the smelting-house where I settled, and the furnaces here shall be utilised for supplying additional steam. I must send a telegram off to-morrow to hurry on that tubing. Bah! I’ll let all that go to-night, and—” “Would you like a little hot water, sir?” Clive Reed started up. “Eh? No, thanks. I don’t shave. Can I have a canful of cold, fresh from the river?” “I have brought one up, sir. Breakfast in half an hour.” Clive Reed was dressed and out in half that space of time, to find the Major busily tying up some beautiful carnations, one of which he cut and presented, dew wet, to his guest. “The most aromatic of our plants, Mr Reed,” he said. “I’m sorry I disturbed you in the night, but it was no false alarm. Look! I would not rake them out till you had seen them.” He pointed to the couple of heavy footprints in the soft soil, and to one of his carnations crushed by a boot heel. “Nothing missing,” continued the Major. “Our friend was startled; but don’t say anything about the footprints at breakfast.” “Certainly not. But are you much troubled in this way?”
  • 78.
    “Well, no,” repliedthe Major, smiling grimly. “The fact is, never. I’m afraid the news of the reopening of the mine has brought some roughs down into the neighbourhood. When you get your men all at work, they’ll be too tired of a night to go wandering about.” “I am very sorry,” said Reed. “Oh, don’t say a word about it, my dear sir. I am not blaming you. I cannot expect to have Derbyshire reserved to me. There! those are smoothed out, and a man who finds that there are firearms upon premises, with people who mean to use them, will think twice before he comes again.” “Yes, of course,” said Reed, looking thoughtfully at the fine old soldierly fellow as he ceased raking his bed. “How will Mademoiselle look this morning? Paler and more startled. A deceitful little minx!” “We’ve ten minutes yet,” said the Major. “Care to walk up to the top of the garden? I can show you where my boundary runs, and yours touches it. Fair play, Mr Engineer. Keep your own side, and don’t come burrowing under me. Hang your rooting and mining! I don’t want to have my garden under- drained and my cottage come toppling about my ears.” “Don’t be alarmed, sir. I shall keep rigorously within the limits of the mapped-out estate.” “Of course you will, my dear sir. I have no fear. It is fascinating work, that mining, though. If I were a young man I might be tempted to begin myself. As you saw indoors, I do dabble a bit in mineralogy and metallurgy. Dinah, too, is quite an expert.”
  • 79.
    “Indeed! I wasnoticing your collection of ores. Some of them very rich.” “Yes; bits I have chipped here and there during the long years of my stay. There we are. Your estate runs—” A shrill whistle arrested him as he stood on the top of a rugged mass of stone, high above the cottage, where luxuriant ferns clustered in every niche; and placing a little silver call which hung by his watch-chain to his lips, he blew an answer. “One is obliged to have something of this kind,” he said smilingly, “to keep our Martha from going mad. That was the breakfast-bell, or answers for it. Fine place this for your appetite, Mr Reed.” “Yes, one does get ready for one’s meals,” replied the guest, as he walked slowly back down the glen-like garden, toward the open window of the room in which they had been seated on the previous evening, and from which Dinah, simply dressed, but looking, with her large eyes and pale creamy cheeks, ten times as interesting as on the previous night, came out to meet them. “A guilty conscience needs no accuser,” thought Reed, as they drew near, but to his intense surprise she held out her hand to him with a sweet, winning frankness, and bade him good morning. Then turning to the Major, a sensation as of a sob rising in his throat affected Reed at the tender affection that seemed to exist between the pair, as Dinah raised her lips to her father’s while he embraced her. “What a brute I am!” thought Clive; and in spite of the sharp rattle of the shot seeming to ring in his ears, he told himself that he must have been wrong.
  • 80.
    “A girl likethat could not be deceitful,” he thought; and when a few minutes later they were seated at the table, and Martha came in, bearing a dish of fried ham, he looked hard at the stern robust woman, and wondered whether she was responsible for the nocturnal visitor. “Impossible!” he said to himself one moment, and the next he owned that it might be so. “Fifty if she’s a day,” he said mentally. “Well, perhaps so, and the lover has come at last.” Two hours later Clive Reed was back in the great shallow gap, where a couple of teams of horses had just dragged up heavy loads of machinery and materials, Sturgess looking morose and speaking in a surly voice, busy ordering the men about the shaft to look sharp and help to unload. The click of hammer and pick was making the place echo. Masons were busy erecting a stone building; and already the place was beginning to look business-like, and as if waking up from its long, long sleep of years. The cottage and its occupants were soon as if they were non-existent to Clive, who went at once into the temporary office which he had had erected, wrote and sent off two telegrams to the nearest town for despatch, several letters, and then, after changing his clothes, went out to descend the mine. He had accidentally arranged his time so that he met Sturgess, who had just ascended. “Ah! Sturgess,” he said, “I wanted to see you. Those rails ought to have been taken down first thing this morning, so that a line might be begun for the small trucks.” “Oh, yes, I know,” said the man roughly. The engineer looked at him wonderingly.
  • 81.
    “Then see aboutit at once.” “Plenty of time, sir; plenty of time,” said Sturgess insolently. “There is not plenty of time, sir,” said Clive, in a tone of voice which rather startled the man; “and have the goodness to understand this:—My late father engaged you on the strength of your recommendations, but I am in supreme authority here, and I submit to insolence from no person in my employ.” “I didn’t mean to be insolent,” grumbled the man. “Then please understand that you were, and don’t venture upon it again, or we part at once. Now go and see that those rails are taken down directly, and that a gang of men begin to lay them at once toward the opening to the great cavern where the water flows.” “No use to lay ’em down there,” grumbled Sturgess. “You heard my orders, sir. I shall be in that direction before long.” Sturgess went out without a word, but with an ugly look upon his countenance. “All right!” he muttered. “Make much of it. People who get up very high have the farther to fall. Curse him! I’ll let him see.” “He must have been drinking,” thought Clive, as soon as he was alone. The next minute he was wrapt in the management of the mine, and giving orders to different men, ending by going to the bucket to be let down, and noting that Sturgess was
  • 82.
    looking at himsearchingly as he rose from bending over the labourers who were lifting the rails.
  • 83.
    Welcome to ourwebsite – the perfect destination for book lovers and knowledge seekers. We believe that every book holds a new world, offering opportunities for learning, discovery, and personal growth. That’s why we are dedicated to bringing you a diverse collection of books, ranging from classic literature and specialized publications to self-development guides and children's books. More than just a book-buying platform, we strive to be a bridge connecting you with timeless cultural and intellectual values. With an elegant, user-friendly interface and a smart search system, you can quickly find the books that best suit your interests. Additionally, our special promotions and home delivery services help you save time and fully enjoy the joy of reading. Join us on a journey of knowledge exploration, passion nurturing, and personal growth every day! ebookbell.com