Etudes for ClojureScript
Companion Exercises for Introducing ClojureScript
Publisher: O'Reilly Media
Release Date: November 2015
Pages: 129
Read on O'Reilly Online Learning with a 10day trial
Start your free trial now Buy on AmazonWhere’s the cart? Now you can get everything with O'Reilly Online Learning. To purchase books, visit Amazon or your favorite retailer. Questions? See our FAQ or contact customer service:
18008898969 / 7078277019
support@oreilly.com
A short composition that provides practice material for a particular musical skill is called an étude. In this handson book, you’ll find more than 30 études to help you practice ClojureScript skills for specific programming areas, ranging from functions and variables to asynchronous processing. Each of these small projects includes a description of a program that you will compose (write) in ClojureScript.
Though not as difficult as their musical counterparts, these programming études will help you stretch beyond the material and examples that you find in most ClojureScript books or online references. One chapter features études for an openended project that will help you put together what you’ve learned. Solutions to each étude are revealed in the appendix.
Programming areas include:
 Working with functions and variables with def and let
 Interacting with JavaScript and web pages, using several libraries
 Lists, vectors, and higherorder map, filter, and reduce functions
 Data mapping with ClojureScript
 Using different ClojureScript libraries to program with React
 Adding, subtracting, multiplying, and dividing rational and complex numbers with defprotocol and defrecord
 Asynchronous processing with core.async
Table of Contents

Chapter 1 Functions and Variables

Étude 11: Defining a Function in the REPL

Étude 12: Defining Functions in a Source File

Étude 13: Using def

Étude 14: Using let

Étude 15: More Practice with def and let


Chapter 2 Interacting with JavaScript and Web Pages

Étude 21: Direct Use of JavaScript

Étude 22: Using Google Closure

Étude 23: Using dommy

Étude 24: Using Domina

Étude 25: Using Enfocus


Chapter 3 Lists, Vectors, and HigherOrder Functions

Étude 31: Move the Zeros

Étude 32: More List Manipulation

Étude 33: Basic Statistics

Étude 34: Basic Statistics in a Web Page

Étude 35: Dental Hygiene

Étude 36: Random Numbers—Generating a Vector of Vectors

Étude 37: Monthly Daylight


Chapter 4 Maps

Étude 41: Condiments

Étude 42: Condiment Server

Étude 43: Maps—Frequency Table

Étude 44: Complex Maps—CrossTabulation

Étude 45: CrossTabulation Server


Chapter 5 Programming with React

Étude 51: Reactive Programming with Quiescent

Étude 52: Reactive Programming with Reagent


Chapter 6 Interlude: Room Usage Project

Étude 61: Build the Data Structure

Étude 62: Visualizing the Data (Version 1)

Étude 63: Visualizing the Data (Version 2)


Chapter 7 Records and Protocols

Étude 71: Rational Numbers

Étude 72: Complex Numbers

Étude 73: Writing Tests


Chapter 8 Asynchronous Processing

Étude 81: A Card Game


Appendix Solutions

Solution 12

Solution 13

Solution 14

Solution 15

Solution 21

Solution 22

Solution 23

Solution 24

Solution 25

Solution 31

Solution 32

Solution 33

Solution 34

Solution 35

Solution 36

Solution 37

Solution 41

Solution 42A

Solution 42B

Solution 43

Solution 44

Solution 45

Solution 51

Solution 52

Solution 61

Solution 62

Solution 63

Solution 71

Solution 72

Solution 73

Sample core.async Program 1

Sample core.async Program 2

Solution 81


Appendix Setting Up Your ClojureScript Environment

Setting Up ClojureScript


Appendix Creating a ClojureScript Project with Leiningen

The mies Template

The figwheel Template


Appendix ClojureScript on the Server

ClojureScript on the Server
