Chapter 1. Introduction to Clojure
Listing 1.1. A small program written in our fictitious XML-based language
Listing 1.2. A slightly less verbose version of the same program
Listing 1.3. Typical duplication in Java code
Listing 1.4. The same code in Clojure, written as is
Listing 1.5. Removing duplication via a domain-specific macro
Chapter 3. Building blocks of Clojure
Listing 3.1. Mutually recursive functions that can blow the stack
Listing 3.2. Mutually recursive functions that can be called with trampoline
Listing 3.3. Function composition using higher-order functions
Listing 3.4. Listing 3.4 Dynamic scope in action
Listing 3.5. A higher-order function for aspect-oriented logging
Chapter 4. Polymorphism with multimethods
Listing 4.1. Implementing the Redis protocol using multimethods
Chapter 5. Clojure and Java interop
Listing 5.1. An abstract Java class that will be used to illustrate gen-class
Listing 5.2. gen-class generates a Java class to reference AbstractJavaClass
Chapter 8. Test-driven development and more
Listing 8.1. Example code that fetches and filters expenses from a data store
Listing 8.2. Simple stubbing and mocking functionality for Clojure tests
Chapter 9. Data storage with Clojure
Listing 9.1. The init-model macro from clj-record.core
Listing 9.2. Contents of a sample hbase-site.xml for a standalone HBase system
Listing 9.3. Transforming Clojure maps into ones suitable for insertion into HBase rows
Listing 9.4. Inserting a Clojure map into an HBase row
Listing 9.5. Reading the flattened map back out from HBase
Listing 9.6. Namespace containing functions exposed to users of this library
Listing 9.7. Namespace containing functions to persist and read back maps from Redis
Chapter 10. Clojure and the web
Listing 10.1. A simple way to expose Clojure functions as web services
Listing 10.2. Extending our basic web service framework to support JSONP callbacks
Listing 10.3. Changes needed to support simple cookie handling
Chapter 11. Scaling through messaging
Listing 11.1. A simple messaging-based distributed-computing framework for Clojure
Listing 11.2. Distributed worker processes to handle worker requests
Listing 11.3. The new multicast-capable messaging code
Listing 11.4. A new implementation of the framework for fire and forget and multicasting
Chapter 12. Data processing with Clojure
Listing 12.1. Computing the frequency of words in given text
Listing 12.2. General map/reduce extracted out of the word-count example
Listing 12.3. Using map/reduce to calculate average number of words in each line
Listing 12.4. The request-seq abstraction for Ruby on Rails log files
Listing 12.5. Analyzing Rails log to compute frequencies of controller calls
Listing 12.6. session-seq built on top of request-seq
Listing 12.7. Computing the average length of sessions from a Rails log file
Listing 12.8. The core namespace for our master/slave batch-processing framework
Listing 12.9. The status namespace for our master/slave batch-processing framework
Chapter 13. More on functional programming
Chapter 14. Protocols, records, and types
Listing 14.1. Skeleton Java class implementing the concept of the expense item
Listing 14.2. Implementing modus operandi on top of multimethods
Listing 14.3. The expense namespace using the modus operandi multimethod syntax
Listing 14.4. Testing the implementation of modus operandi calculating expense totals
Listing 14.5. The expense namespace using a Clojure protocol
Listing 14.6. The expense namespace using a Clojure protocol and defrecord
Listing 14.7. The expense namespace with defrecord and inline protocol
Chapter 15. More macros and DSLs
Listing 15.1. A general rotation cipher system to implement things like ROT13
Listing 15.2. Basic functions to handle session persistence in Redis
Listing 15.3. The dsl-store namespace for storing the rules as anonymous functions
Listing 15.4. The segmentation DSL defined using a simple macro
Listing 15.5. The simple DSL execution engine to classify users into segments
3.144.30.62