ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 02.01.2026
Просмотров: 3408
Скачиваний: 0
|
List of Tables |
xxv |
24.11 |
Performance characteristics of set and map types . . . . . . |
586 |
24.12 |
Operations in trait Iterator . . . . . . . . . . . . . . . . |
595 |
24.13 |
Factory methods for sequences . . . . . . . . . . . . . . . |
602 |
33.1 |
Summary of parser combinators . . . . . . . . . . . . . . . |
770 |
Cover · Overview · Contents · Discuss · Suggest · Glossary · Index
List of Listings
3.1 |
Parameterizing an array with a type. . . . . . . . . . . . . |
82 |
3.2 |
Creating and initializing an array. . . . . . . . . . . . . . . |
85 |
3.3 |
Creating and initializing a list. . . . . . . . . . . . . . . . . |
86 |
3.4 |
Creating and using a tuple. . . . . . . . . . . . . . . . . . |
90 |
3.5 |
Creating, initializing, and using an immutable set. . . . . . |
91 |
3.6 |
Creating, initializing, and using a mutable set. . . . . . . . |
93 |
3.7 |
Creating, initializing, and using a mutable map. . . . . . . |
94 |
3.8 |
Creating, initializing, and using an immutable map. . . . . |
95 |
3.9 |
A function without side effects or vars. . . . . . . . . . . . |
97 |
3.10 |
Reading lines from a file. . . . . . . . . . . . . . . . . . . |
99 |
3.11 |
Printing formatted character counts for the lines of a file. . |
102 |
4.1 |
Final version of class ChecksumAccumulator. . . . . . . . |
107 |
4.2 |
Companion object for class ChecksumAccumulator. . . . . |
110 |
4.3 |
The Summer application. . . . . . . . . . . . . . . . . . . . |
112 |
4.4 |
Using the Application trait. . . . . . . . . . . . . . . . . |
115 |
6.1 |
Rational with fields. . . . . . . . . . . . . . . . . . . . . |
145 |
6.2 |
Rational with an auxiliary constructor. . . . . . . . . . . |
147 |
6.3 |
Rational with a private field and method. . . . . . . . . . |
148 |
6.4 |
Rational with operator methods. . . . . . . . . . . . . . . |
150 |
6.5 |
Rational with overloaded methods. . . . . . . . . . . . . |
155 |
7.1 |
Scala’s idiom for conditional initialization. . . . . . . . . . |
160 |
7.2 |
Calculating greatest common divisor with a while loop. . . |
161 |
7.3 |
Reading from the standard input with do-while. . . . . . . |
162 |
7.4 |
Calculating greatest common divisor with recursion. . . . . |
163 |
7.5 |
Listing files in a directory with a for expression. . . . . . . |
164 |
xxvi
|
List of Listings |
xxvii |
7.6 |
Finding .scala files using a for with a filter. . . . . . . . |
166 |
7.7 |
Using multiple filters in a for expression. . . . . . . . . . |
166 |
7.8 |
Using multiple generators in a for expression. . . . . . . . |
167 |
7.9 |
Mid-stream assignment in a for expression. . . . . . . . . |
168 |
7.10 |
Transforming an Array[File] to Array[Int] with a for. |
169 |
7.11 |
A try-catch clause in Scala. . . . . . . . . . . . . . . . . |
171 |
7.12 |
A try-finally clause in Scala. . . . . . . . . . . . . . . |
172 |
7.13 |
A catch clause that yields a value. . . . . . . . . . . . . . |
173 |
7.14 |
A match expression with side effects. . . . . . . . . . . . . |
174 |
7.15 |
A match expression that yields a value. . . . . . . . . . . . |
174 |
7.16 |
Looping without break or continue. . . . . . . . . . . . . |
176 |
7.17 |
A recursive alternative to looping with vars. . . . . . . . . |
176 |
7.18 |
Variable scoping when printing a multiplication table. . . . |
179 |
7.19 |
A functional way to create a multiplication table. . . . . . . |
182 |
8.1 |
LongLines with a private processLine method. . . . . . . |
185 |
8.2 |
LongLines with a local processLine function. . . . . . . |
187 |
8.3 |
A parameter with a default value. . . . . . . . . . . . . . . |
201 |
8.4 |
A function with two parameters that have defaults. . . . . . |
202 |
9.1 |
Using closures to reduce code duplication. . . . . . . . . . |
211 |
9.2 |
Defining and invoking a “plain old” function. . . . . . . . . |
214 |
9.3 |
Defining and invoking a curried function. . . . . . . . . . . |
214 |
9.4 |
Using the loan pattern to write to a file. . . . . . . . . . . . |
218 |
9.5 |
Using a by-name parameter. . . . . . . . . . . . . . . . . . |
219 |
10.1 |
Defining an abstract method and class. . . . . . . . . . . . |
224 |
10.2 |
Defining parameterless methods width and height. . . . . |
225 |
10.3 |
Defining ArrayElement as a subclass of Element. . . . . . |
227 |
10.4 |
Overriding a parameterless method with a field. . . . . . . |
229 |
10.5 |
Defining contents as a parametric field. . . . . . . . . . . |
231 |
10.6 |
Invoking a superclass constructor. . . . . . . . . . . . . . . |
232 |
10.7 |
Declaring a final method. . . . . . . . . . . . . . . . . . . |
238 |
10.8 |
Declaring a final class. . . . . . . . . . . . . . . . . . . . . |
238 |
10.9 |
Class Element with above, beside, and toString. . . . . |
243 |
10.10 |
A factory object with factory methods. . . . . . . . . . . . |
244 |
10.11 |
Class Element refactored to use factory methods. . . . . . |
245 |
10.12 |
Hiding implementation with private classes. . . . . . . . . |
246 |
Cover · Overview · Contents · Discuss · Suggest · Glossary · Index
|
List of Listings |
xxviii |
10.13 |
Element with widen and heighten methods. . . . . . . . |
247 |
10.14 |
The Spiral application. . . . . . . . . . . . . . . . . . . . |
248 |
12.1 |
The definition of trait Philosophical. . . . . . . . . . . . |
258 |
12.2 |
Mixing in a trait using extends. . . . . . . . . . . . . . . |
259 |
12.3 |
Mixing in a trait using with. . . . . . . . . . . . . . . . . |
260 |
12.4 |
Mixing in multiple traits. . . . . . . . . . . . . . . . . . . |
260 |
12.5 |
Defining an enrichment trait. . . . . . . . . . . . . . . . . |
264 |
12.6 |
Abstract class IntQueue. . . . . . . . . . . . . . . . . . . |
268 |
12.7 |
A BasicIntQueue implemented with an ArrayBuffer. . . |
268 |
12.8 |
The Doubling stackable modification trait. . . . . . . . . . |
269 |
12.9 |
Mixing in a trait when instantiating with new. . . . . . . . . |
270 |
12.10 |
Stackable modification traits Incrementing and Filtering. |
270 |
13.1 |
Placing the contents of an entire file into a package. . . . . |
278 |
13.2 |
Long form of a simple package declaration. . . . . . . . . |
278 |
13.3 |
Multiple packages in the same file. . . . . . . . . . . . . . |
279 |
13.4 |
Concise access to classes and packages. . . . . . . . . . . . |
279 |
13.5 |
Symbols in enclosing packages not automatically available. |
280 |
13.6 |
Accessing hidden package names. . . . . . . . . . . . . . . |
280 |
13.7 |
Bob’s delightful fruits, ready for import. . . . . . . . . . . |
283 |
13.8 |
Importing the members of a regular (not singleton) object. . |
283 |
13.9 |
Importing a package name. . . . . . . . . . . . . . . . . . |
284 |
13.10 |
How private access differs in Scala and Java. . . . . . . . . |
287 |
13.11 |
How protected access differs in Scala and Java. . . . . . . . |
288 |
13.12 |
Flexible scope of protection with access qualifiers. . . . . . |
289 |
13.13 |
Accessing private members of companion classes and objects. |
292 |
13.14 |
A package object. . . . . . . . . . . . . . . . . . . . . . . |
293 |
14.1 |
Using an assertion. . . . . . . . . . . . . . . . . . . . . . . |
296 |
14.2 |
Using ensuring to assert a function’s result. . . . . . . . . |
296 |
14.3 |
Writing a test method with Suite. . . . . . . . . . . . . . |
297 |
14.4 |
Writing a test function with FunSuite. . . . . . . . . . . . |
298 |
14.5 |
Writing a JUnit test with JUnit3Suite. . . . . . . . . . . |
301 |
14.6 |
Writing a TestNG test with TestNGSuite. . . . . . . . . . |
302 |
14.7 |
Specifying and testing behavior with a ScalaTest FlatSpec. |
303 |
14.8 |
Specifying and testing behavior with the specs framework. . |
304 |
14.9 |
Writing property-based tests with ScalaCheck. . . . . . . . |
305 |
Cover · Overview · Contents · Discuss · Suggest · Glossary · Index
|
List of Listings |
xxix |
15.1 |
Defining case classes. . . . . . . . . . . . . . . . . . . . . |
310 |
15.2 |
The simplifyTop function, which does a pattern match. . . |
312 |
15.3 |
A pattern match with an empty “default” case. . . . . . . . |
314 |
15.4 |
A pattern match with wildcard patterns. . . . . . . . . . . . |
315 |
15.5 |
A pattern match with constant patterns. . . . . . . . . . . . |
315 |
15.6 |
A pattern match with a variable pattern. . . . . . . . . . . . |
316 |
15.7 |
A pattern match with a constructor pattern. . . . . . . . . . |
318 |
15.8 |
A sequence pattern with a fixed length. . . . . . . . . . . . |
318 |
15.9 |
A sequence pattern with an arbitrary length. . . . . . . . . |
319 |
15.10 |
A pattern match with a tuple pattern. . . . . . . . . . . . . |
319 |
15.11 |
A pattern match with typed patterns. . . . . . . . . . . . . |
320 |
15.12 |
Using isInstanceOf and asInstanceOf (poor style). . . . |
321 |
15.13 |
A pattern with a variable binding (via the @ sign). . . . . . |
323 |
15.14 |
A match expression with a pattern guard. . . . . . . . . . . |
324 |
15.15 |
Match expression in which case order matters. . . . . . . . |
325 |
15.16 |
A sealed hierarchy of case classes. . . . . . . . . . . . . . |
327 |
15.17 |
Defining multiple variables with one assignment. . . . . . . |
330 |
15.18 |
A for expression with a tuple pattern. . . . . . . . . . . . |
334 |
15.19 |
Picking elements of a list that match a pattern. . . . . . . . |
334 |
15.20 |
The top half of the expression formatter. . . . . . . . . . . |
337 |
15.21 |
The bottom half of the expression formatter. . . . . . . . . |
338 |
15.22 |
An application that prints formatted expressions. . . . . . . |
341 |
16.1 |
A merge sort function for Lists. . . . . . . . . . . . . . . |
360 |
17.1 |
Default map and set definitions in Predef. . . . . . . . . . |
382 |
18.1 |
A mutable bank account class. . . . . . . . . . . . . . . . . |
400 |
18.2 |
A class with public vars. . . . . . . . . . . . . . . . . . . |
402 |
18.3 |
How public vars are expanded into getter and setter methods. |
403 |
18.4 |
Defining getter and setter methods directly. . . . . . . . . . |
403 |
18.5 |
Defining a getter and setter without an associated field. . . |
404 |
18.6 |
The halfAdder method. . . . . . . . . . . . . . . . . . . . |
407 |
18.7 |
The fullAdder method. . . . . . . . . . . . . . . . . . . . |
408 |
18.8 |
The Simulation class. . . . . . . . . . . . . . . . . . . . |
410 |
18.9 |
The first half of the BasicCircuitSimulation class. . . . |
414 |
18.10 |
The second half of the BasicCircuitSimulation class. . |
415 |
18.11 |
The CircuitSimulation class. . . . . . . . . . . . . . . . |
419 |
Cover · Overview · Contents · Discuss · Suggest · Glossary · Index