Preface |
|
xvii | |
Acknowledgments |
|
xix | |
About this book |
|
xxi | |
About the author |
|
xxv | |
About the cover illustration |
|
xxvi | |
|
|
1 | (118) |
|
|
3 | (13) |
|
|
4 | (1) |
|
Pros and cons of statically and dynamically typed languages |
|
|
4 | (1) |
|
1.2 Julia combines elegance, productivity, and performance |
|
|
5 | (1) |
|
1.3 Why Julia was created |
|
|
6 | (3) |
|
Scientists need the interactive programming that dynamically typed languages offer |
|
|
7 | (1) |
|
Developers in other fields also need the interactivity a dynamically typed language offers |
|
|
8 | (1) |
|
1.4 Julia's higher performance solves the two-language problem |
|
|
9 | (1) |
|
1.5 Julia is for everyone |
|
|
10 | (1) |
|
1.6 What can I build with Julia? |
|
|
11 | (1) |
|
|
11 | (1) |
|
|
12 | (1) |
|
1.7 Where Julia is less ideal |
|
|
12 | (1) |
|
1.8 What you will learn in this book |
|
|
13 | (3) |
|
|
16 | (18) |
|
2.1 The Julia command line |
|
|
17 | (1) |
|
2.2 Using constants and variables |
|
|
18 | (5) |
|
Assigning and binding values to variables |
|
|
21 | (1) |
|
|
22 | (1) |
|
What is a literal coefficient? |
|
|
23 | (1) |
|
2.3 Different number types and their bit length in Julia |
|
|
23 | (3) |
|
Writing numbers using different number formats |
|
|
25 | (1) |
|
2.4 Floating-point numbers |
|
|
26 | (1) |
|
Performing operations on integers and floating-point numbers |
|
|
27 | (1) |
|
|
27 | (5) |
|
Storing function definitions in a file |
|
|
29 | (1) |
|
Working with functions in the REPL |
|
|
30 | (1) |
|
|
30 | (1) |
|
Functions to work with numbers |
|
|
31 | (1) |
|
2.6 How to use numbers in practice |
|
|
32 | (2) |
|
|
34 | (25) |
|
3.1 Navigation and trigonometry |
|
|
35 | (2) |
|
|
37 | (2) |
|
|
38 | (1) |
|
|
39 | (6) |
|
|
41 | (1) |
|
Making a mathematical table for the sine function |
|
|
42 | (2) |
|
|
44 | (1) |
|
|
44 | (1) |
|
|
45 | (2) |
|
Implementing the sine trigonometric function |
|
|
46 | (1) |
|
3.5 Implementing factorial |
|
|
47 | (1) |
|
3.6 Factorial with recursion |
|
|
48 | (1) |
|
|
49 | (2) |
|
|
49 | (1) |
|
|
50 | (1) |
|
3.8 Throwing exceptions to handle errors |
|
|
51 | (2) |
|
3.9 Control flow vs. data flow |
|
|
53 | (1) |
|
|
54 | (5) |
|
|
56 | (1) |
|
|
56 | (1) |
|
|
57 | (2) |
|
|
59 | (27) |
|
4.1 Analyzing pizza sales |
|
|
60 | (1) |
|
4.2 Different types of arrays |
|
|
61 | (1) |
|
4.3 Performing operations on arrays |
|
|
62 | (3) |
|
4.4 Working with the statistics module |
|
|
65 | (2) |
|
|
67 | (2) |
|
|
69 | (2) |
|
4.7 Mapping values in an array |
|
|
71 | (3) |
|
4.8 Introducing characters and strings |
|
|
74 | (3) |
|
4.9 Storing pizza data in tuples |
|
|
77 | (3) |
|
4.10 Filtering pizzas based on predicates |
|
|
80 | (2) |
|
Combining higher-order functions |
|
|
81 | (1) |
|
4.11 Mapping and reducing an array |
|
|
82 | (2) |
|
Sine table with map and reduce |
|
|
83 | (1) |
|
4.12 Counting matches with Boolean arrays |
|
|
84 | (2) |
|
|
86 | (33) |
|
5.1 Making a pretty pizza sales table |
|
|
87 | (8) |
|
Print, printIn, and printstyled |
|
|
88 | (3) |
|
Printing multiple elements |
|
|
91 | (1) |
|
|
92 | (1) |
|
|
92 | (2) |
|
|
94 | (1) |
|
5.2 Printing a trigonometric table |
|
|
95 | (2) |
|
5.3 Reading and writing pizza sales to CSV files |
|
|
97 | (4) |
|
Writing pizza sales to a file |
|
|
98 | (1) |
|
Reading pizza sales from a file |
|
|
99 | (2) |
|
5.4 Interacting with the user |
|
|
101 | (4) |
|
Storing data in dictionaries |
|
|
104 | (1) |
|
6.1 Parsing Roman numerals |
|
|
105 | (1) |
|
|
106 | (2) |
|
6.3 Looping over characters |
|
|
108 | (1) |
|
6.4 Enumerating values and indices |
|
|
109 | (1) |
|
6.5 Explaining the conversion process |
|
|
110 | (1) |
|
|
111 | (3) |
|
|
111 | (2) |
|
|
113 | (1) |
|
6.7 Why use a dictionary? |
|
|
114 | (2) |
|
6.8 Using named tuples as dictionaries |
|
|
116 | (3) |
|
When do you use a named tuple? |
|
|
117 | (1) |
|
|
118 | (1) |
|
|
119 | (68) |
|
|
121 | (20) |
|
7.1 Creating composite types from primitive types |
|
|
122 | (2) |
|
7.2 Exploring type hierarchies |
|
|
124 | (3) |
|
7.3 Creating a battle simulator |
|
|
127 | (9) |
|
|
128 | (2) |
|
Adding behavior to warriors |
|
|
130 | (2) |
|
Using multiple dispatch to invoke methods |
|
|
132 | (4) |
|
7.4 How Julia selects method to call |
|
|
136 | (5) |
|
Contrasting Julia's multiple dispatch with object-oriented languages |
|
|
138 | (1) |
|
How is multiple dispatch different from function overloading? |
|
|
139 | (2) |
|
|
141 | (19) |
|
8.1 Building a simple rocket |
|
|
142 | (4) |
|
8.2 Maintaining invariants in your code |
|
|
146 | (1) |
|
8.3 Making objects with constructor functions |
|
|
147 | (1) |
|
8.4 Differences between outer and inner constructors |
|
|
148 | (1) |
|
8.5 Modeling rocket engines and payloads |
|
|
149 | (2) |
|
8.6 Assembling a simple rocket |
|
|
151 | (1) |
|
8.7 Creating a rocket with multiple stages and engines |
|
|
152 | (4) |
|
8.8 Launching a rocket into space |
|
|
156 | (4) |
|
9 Conversion and promotion |
|
|
160 | (16) |
|
9.1 Exploring Julia's number promotion system |
|
|
161 | (2) |
|
9.2 Understanding number conversion |
|
|
163 | (3) |
|
9.3 Defining custom units for angles |
|
|
166 | (10) |
|
Defining angle constructors |
|
|
168 | (1) |
|
Defining arithmetic operations on angles |
|
|
168 | (2) |
|
Defining accessors to extract degrees, minutes, and seconds |
|
|
170 | (1) |
|
|
170 | (1) |
|
Defining type conversions |
|
|
171 | (1) |
|
|
172 | (1) |
|
|
173 | (3) |
|
10 Representing unknown values |
|
|
176 | (11) |
|
|
177 | (1) |
|
10.2 Using nothing in data structures |
|
|
178 | (4) |
|
What is a parametric type? |
|
|
179 | (1) |
|
Using union types to end the wagon train |
|
|
180 | (2) |
|
|
182 | (1) |
|
|
183 | (1) |
|
|
184 | (1) |
|
10.6 Putting it all together |
|
|
184 | (3) |
|
|
187 | (88) |
|
|
189 | (28) |
|
|
190 | (6) |
|
Understanding the relation between code points and code units |
|
|
191 | (5) |
|
|
196 | (9) |
|
Converting from camel case to snake case |
|
|
198 | (2) |
|
Converting between numbers and strings |
|
|
200 | (2) |
|
String interpolation and concatenation |
|
|
202 | (2) |
|
|
204 | (1) |
|
11.3 Using string interpolation to generate code |
|
|
205 | (3) |
|
11.4 Working with nonstandard string literals |
|
|
208 | (9) |
|
|
209 | (1) |
|
|
210 | (1) |
|
Using regular expressions to match text |
|
|
211 | (3) |
|
Making large integers with BigInt |
|
|
214 | (1) |
|
|
215 | (2) |
|
12 Understanding Julia collections |
|
|
217 | (25) |
|
|
218 | (2) |
|
12.2 Propellant tank interface example |
|
|
220 | (4) |
|
12.3 Interfaces by convention |
|
|
224 | (1) |
|
12.4 Implementing engine cluster iteration |
|
|
225 | (4) |
|
|
227 | (2) |
|
12.5 Implementing rocket stage iteration |
|
|
229 | (4) |
|
Adding support for map and collect |
|
|
231 | (2) |
|
12.6 Comparison of linked lists and arrays |
|
|
233 | (7) |
|
Adding and removing elements |
|
|
235 | (5) |
|
12.7 Utility of custom types |
|
|
240 | (2) |
|
|
242 | (18) |
|
13.1 What kind of problems can sets help solve? |
|
|
243 | (1) |
|
|
244 | (5) |
|
Comparing properties of sets and arrays |
|
|
245 | (4) |
|
13.3 How to use set operations |
|
|
249 | (2) |
|
13.4 How to use sets in your code |
|
|
251 | (1) |
|
13.5 Searching for products using set operations |
|
|
252 | (5) |
|
Defining and using enumerations |
|
|
254 | (1) |
|
Creating test data to perform queries on |
|
|
254 | (1) |
|
|
255 | (1) |
|
Putting screw objects into sets |
|
|
256 | (1) |
|
Looking up screws using dictionaries |
|
|
256 | (1) |
|
13.6 Search in bug tracker using sets |
|
|
257 | (1) |
|
13.7 Relational databases and sets |
|
|
258 | (2) |
|
14 Working with vectors and matrices |
|
|
260 | (15) |
|
14.1 Vectors and matrices in mathematics |
|
|
261 | (1) |
|
14.2 Constructing a matrix from rows and columns |
|
|
261 | (1) |
|
14.3 The size, length, and norm of an array |
|
|
262 | (2) |
|
14.4 Slicing and dicing an array |
|
|
264 | (5) |
|
14.5 Combining matrices and vectors |
|
|
269 | (3) |
|
|
272 | (3) |
|
Part 4 Software engineering |
|
|
275 | (46) |
|
15 Functional programming in Julia |
|
|
277 | (22) |
|
15.1 How does functional programming differ from object-oriented programming? |
|
|
278 | (1) |
|
15.2 How and why you should learn to think functionally |
|
|
279 | (1) |
|
15.3 Avoid deeply nested calls with function chaining |
|
|
279 | (5) |
|
Understanding anonymous functions and closures |
|
|
281 | (1) |
|
|
282 | (1) |
|
Conveniently produce new functions using partial application |
|
|
282 | (2) |
|
15.4 Implementing Caesar and substitution ciphers |
|
|
284 | (5) |
|
Implementing the Caesar cipher |
|
|
285 | (2) |
|
Implementing substitution ciphers |
|
|
287 | (2) |
|
15.5 Creating a cipher-algorithm-agnostic service |
|
|
289 | (1) |
|
15.6 Building an encryption service using object-oriented programming |
|
|
290 | (3) |
|
15.7 Building an encryption service using functional programming |
|
|
293 | (6) |
|
Defining a functional Caesar cipher |
|
|
294 | (1) |
|
Defining a functional substitution cipher |
|
|
295 | (1) |
|
Implementing a functional password-keeper service |
|
|
296 | (3) |
|
16 Organizing and modularizing your code |
|
|
299 | (22) |
|
16.1 Setting up a work environment |
|
|
300 | (6) |
|
Using a package in the REPL |
|
|
303 | (2) |
|
How modules relate to packages |
|
|
305 | (1) |
|
16.2 Creating your own package and module |
|
|
306 | (5) |
|
|
306 | (3) |
|
Adding code to your package |
|
|
309 | (2) |
|
16.3 Modifying and developing a package |
|
|
311 | (4) |
|
16.4 Tackling common misconceptions about modules |
|
|
315 | (1) |
|
16.5 Testing your package |
|
|
316 | (5) |
|
|
321 | (25) |
|
|
323 | (12) |
|
17.1 Introducing Julia's I/O system |
|
|
324 | (2) |
|
17.2 Reading data from a process |
|
|
326 | (1) |
|
17.3 Reading and writing to a socket |
|
|
327 | (1) |
|
|
328 | (7) |
|
Loading rocket engine data |
|
|
330 | (3) |
|
Saving rocket engine data |
|
|
333 | (2) |
|
18 Defining parametric types |
|
|
335 | (11) |
|
18.1 Defining parametric methods |
|
|
336 | (2) |
|
18.2 Defining parametric types |
|
|
338 | (2) |
|
18.3 Type safety benefits from parametric types |
|
|
340 | (3) |
|
18.4 Performance benefits from parametric types |
|
|
343 | (2) |
|
18.5 Memory benefits of parametric types |
|
|
345 | (1) |
Appendix A Installing and configuring the Julia environment |
|
346 | (7) |
Appendix B Numerics |
|
353 | (8) |
Index |
|
361 | |