Definingfunctions 26 Simplifying def and defn 27 In-fAacefunctions
•
*
with
*
28
Locals, loops, and blocks 29
Locals
'
32
29
from
Preventing things
29
33
Unquote Auto-gensym 36
35
operator The..
36 37
SettingJava
*
37*
macro
36
AccessingJava
*
pitch
The doto
and catch
34
Creatingfava
class
instance members with the
instance properties macro
Exceptional circumstances A little
*
36
static class members
instances
32
happening: quoting
Leveragingjava via interop Accessing
30
Loops
-
Quoting
•
Unquole-splicing
2.9
*
28
Evaluation
2.8
25
Maps
*
28
Blocks
2.7
24
collections
Declaring bindings using def
2.6
*
Making things happen: functions
'with #()
2.5
Floating-point numbers 22 Keywords 23 Strings 23
23
Callingfunctions function definitions 2.4
22
Integers Symbols
Putting things together: Lists
2.3
*
22
Characters
2.2
20
Clojure firehose
38*
.
37
Defining classes
38
38
38
39
Namespaces
Creating namespaces using ns 39 Loading other namespaces 40 with .-require Loading and creatingmappings with :use 40 Creating mappings with .refer 41 LoadingJava classes with .import 42 *
*
*
2.10
Summary
Dipping our toes 3.1
42
in the pool
Truthiness
44
Wfiat's truth?
nil 3.2
versus
43
false
Nil pun with
44
*
Don't create Boolean
45
care
45
objects
44
xi
CONTENTS
3.3
Your
assignment,
Destructuring Destructuring
Using
should you choose to accept it
with
47
a vector
in function
methods
accessor
3.4
47
Destructuring
the REPL to
1^I. 2
Destructuring
parameters
50*
with
a
map
49
Destructuring versus
51
experiment *
Summary
47
50
Experimenting with seqs 51 Putting it all together 54 fust forfun 56 3.5
•
Experimenting with graphics things go wrong 54
52
When
56
D.A.T.A. ^JPYIPIi(S& •«««»««»«tt«»*««*e««0*«»**««»««»«»«*»c«*»«»»««»»0**»««»0159 On scalars 4.1
61
Understanding precision Truncation
Trying
Why be rational? rationality 67 4.3
When
to use
How
are
66
66
*
71
73
Summary
*
Symbols
Functions
68'
Qualifying your
and
71
namespaces
*
74
77
"
means.
•
Beware
Lisp-1
72
73
of mutable matchers
75
75
keep using
Vectors:
of
70
76
Persistence, sequences, and
Big-0
Caveats
68
Regular expressions—the second problem
"You
5.2
How to be rational
*
keywords
Composite data types 5.1
65
Symbolic resolution
Syntax 4.6
64
Overflow 64
69
Metadata
4.5
*
keywords different from symbols?
keywords 4.4
63
Rounding errors
*
be rational
to
62
Promotion
*
64
Underflow 4.2
62
*
complexity
that word. I do not think it
Sequence
terms and what
77 what you think it 78 mean
means
they
81
creating and using them in all their varieties 82
Building vectors
*
Large
vectors
83
Vectors
Using vectors instead of reverse 87* Subvectors MapEntries 88 What vectors aren't 89 *
as
88*
82
stacks Vectors
86 as
xii
CONTENTS
5.3
Lists:
Clojure's code form data
How
to use
93
things Persistent B asic
*
stacks
91
What lists
*
*
92
on
*
Getting
94 94
properties of Clojure sets 94
95
contains?
*
Keeping your sets in
•
order with
96
closure.set
*
97
in maps
Thinking
91
nothing 92 Putting things Taking things off 93
sets
sorted-set 5.6
as
persistent queues
A queue about
5.5
Lists
*
91
arm't
5.4
90
Lisps like
Lists like
90
structure
Hash maps
97* Keeping your keys in order with sorted maps Keeping your insertions in order with array maps 100 5.7
Putting it all together: finding in
a
Part 3
sequence
Being lazy 6.1
On
101
6.2
Designing
a
6.3
Laziness
113
108* Being set in your ways—
115
recipe
6.5
Summary
logical-and
Losing your
*
all
together:
a
*
117
Understanding the lazyEmploying infinite *
macros
lazy quicksort
119
121
124
Functional programming
125
Functions in all their forms First-class functions
of coercion: don't 288 Corollary: you 're probably not doing it right 288 Second rule of coercion: don't 290 Third rule of coercion: coerce a stable local 290 Fourth rule of *
*
coercion: watch your sizes only as a goal 290
12.6
DSLs
the way you think
ubiquitous DSL specification 294 DSLs
293
Putting parentheses around the Clojure's approach to