100% found this document useful (1 vote)
23 views

Programming in Scala 1st Edition Martin Odersky instant download

Programming in Scala is a comprehensive guide authored by Martin Odersky, Lex Spoon, and Bill Venners, focusing on the Scala programming language. The first edition, published in 2008, covers various aspects of Scala including its syntax, functional programming features, and object-oriented principles. The document also provides links to additional Scala-related resources and textbooks.

Uploaded by

jorimghdrn
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
23 views

Programming in Scala 1st Edition Martin Odersky instant download

Programming in Scala is a comprehensive guide authored by Martin Odersky, Lex Spoon, and Bill Venners, focusing on the Scala programming language. The first edition, published in 2008, covers various aspects of Scala including its syntax, functional programming features, and object-oriented principles. The document also provides links to additional Scala-related resources and textbooks.

Uploaded by

jorimghdrn
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

Programming in Scala 1st Edition Martin Odersky

pdf download

https://ebookfinal.com/download/programming-in-scala-1st-edition-
martin-odersky/

Explore and download more ebooks or textbooks


at ebookfinal.com
Here are some recommended products for you. Click the link to
download, or explore more at ebookfinal

Programming in Scala A Comprehensive Step by Step Guide


Third Edition Martin Odersky

https://ebookfinal.com/download/programming-in-scala-a-comprehensive-
step-by-step-guide-third-edition-martin-odersky/

Functional Programming in Scala 1st Edition Paul Chiusano

https://ebookfinal.com/download/functional-programming-in-scala-1st-
edition-paul-chiusano/

Scala in Action Nilanjan Raychaudhuri

https://ebookfinal.com/download/scala-in-action-nilanjan-raychaudhuri/

Desire in the Canterbury Tales 1st Edition Elizabeth Scala

https://ebookfinal.com/download/desire-in-the-canterbury-tales-1st-
edition-elizabeth-scala/
Scala Design Patterns 1st Edition Nikolov

https://ebookfinal.com/download/scala-design-patterns-1st-edition-
nikolov/

Game Programming Golden Rules Game Development Series 1st


Edition Martin Brownlow

https://ebookfinal.com/download/game-programming-golden-rules-game-
development-series-1st-edition-martin-brownlow/

Mastering Play Framework for Scala 1st Edition Saxena

https://ebookfinal.com/download/mastering-play-framework-for-
scala-1st-edition-saxena/

Programming in Ada 2012 1st Edition John Barnes

https://ebookfinal.com/download/programming-in-ada-2012-1st-edition-
john-barnes/

Programming MapPoint in NET 1st Edition Chandu Thota

https://ebookfinal.com/download/programming-mappoint-in-net-1st-
edition-chandu-thota/
Programming in Scala 1st Edition Martin Odersky Digital
Instant Download
Author(s): Martin Odersky, Lex Spoon, Bill Venners
ISBN(s): 9780981531601, 0981531601
Edition: 1st
File Details: PDF, 2.46 MB
Year: 2008
Language: english
Cover · Overview · Contents · Discuss · Suggest · Glossary · Index
Programming in Scala

Cover · Overview · Contents · Discuss · Suggest · Glossary · Index


Programming in Scala
Martin Odersky, Lex Spoon, Bill Venners

artima
A RTIMA P RESS
M OUNTAIN V IEW, C ALIFORNIA

Cover · Overview · Contents · Discuss · Suggest · Glossary · Index


iv

Programming in Scala
First Edition, Version 6

Martin Odersky is the creator of the Scala language and a professor at EPFL in
Lausanne, Switzerland. Lex Spoon worked on Scala for two years as a post-doc
with Martin Odersky. Bill Venners is president of Artima, Inc.

Artima Press is an imprint of Artima, Inc.


P.O. Box 390122, Mountain View, California 94039

Copyright © 2007, 2008 Martin Odersky, Lex Spoon, and Bill Venners.
All rights reserved.

First edition published as PrePrint™ eBook 2007


First edition published 2008
Produced in the United States of America

12 11 10 09 08 56789

ISBN-10: 0-9815316-1-X
ISBN-13: 978-0-9815316-1-8

No part of this publication may be reproduced, modified, distributed, stored in a


retrieval system, republished, displayed, or performed, for commercial or
noncommercial purposes or for compensation of any kind without prior written
permission from Artima, Inc.

All information and materials in this book are provided "as is" and without
warranty of any kind.

The term “Artima” and the Artima logo are trademarks or registered trademarks of
Artima, Inc. All other company and/or product names may be trademarks or
registered trademarks of their owners.

Cover · Overview · Contents · Discuss · Suggest · Glossary · Index


to Nastaran - M.O.
to Fay - L.S.
to Siew - B.V.

Cover · Overview · Contents · Discuss · Suggest · Glossary · Index


Overview
Contents vii
List of Figures xvii
List of Tables xix
List of Listings xx
Foreword xxvii
Acknowledgments xxix
Introduction xxxi
1. A Scalable Language 39
2. First Steps in Scala 58
3. Next Steps in Scala 71
4. Classes and Objects 93
5. Basic Types and Operations 107
6. Functional Objects 129
7. Built-in Control Structures 149
8. Functions and Closures 173
9. Control Abstraction 194
10. Composition and Inheritance 209
11. Scala’s Hierarchy 237
12. Traits 245
13. Packages and Imports 264
14. Assertions and Unit Testing 279
15. Case Classes and Pattern Matching 293
16. Working with Lists 327
17. Collections 359
18. Stateful Objects 387
19. Type Parameterization 410
20. Abstract Members 435
21. Implicit Conversions and Parameters 465
22. Implementing Lists 487
23. For Expressions Revisited 500
24. Extractors 516
25. Annotations 532
26. Working with XML 539
27. Modular Programming Using Objects 553
28. Object Equality 568
29. Combining Scala and Java 594
30. Actors and Concurrency 607
31. Combinator Parsing 642
32. GUI Programming 671
33. The SCells Spreadsheet 683
A. Scala scripts on Unix and Windows 708
Glossary 709
Bibliography 725
About the Authors 728
Index 729

Cover · Overview · Contents · Discuss · Suggest · Glossary · Index


Contents

Contents vii

List of Figures xvii

List of Tables xix

List of Listings xx

Foreword xxvii

Acknowledgments xxix

Introduction xxxi

1 A Scalable Language 39
1.1 A language that grows on you . . . . . . . . . . . . . . 40
1.2 What makes Scala scalable? . . . . . . . . . . . . . . . 45
1.3 Why Scala? . . . . . . . . . . . . . . . . . . . . . . . . 48
1.4 Scala’s roots . . . . . . . . . . . . . . . . . . . . . . . 55
1.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 57

2 First Steps in Scala 58


Step 1. Learn to use the Scala interpreter . . . . . . . . . . . . 58
Step 2. Define some variables . . . . . . . . . . . . . . . . . 60
Step 3. Define some functions . . . . . . . . . . . . . . . . . 62
Step 4. Write some Scala scripts . . . . . . . . . . . . . . . . 64
Step 5. Loop with while; decide with if . . . . . . . . . . . 65
Step 6. Iterate with foreach and for . . . . . . . . . . . . . 67
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

Cover · Overview · Contents · Discuss · Suggest · Glossary · Index


Contents viii

3 Next Steps in Scala 71


Step 7. Parameterize arrays with types . . . . . . . . . . . . 71
Step 8. Use lists . . . . . . . . . . . . . . . . . . . . . . . . 75
Step 9. Use tuples . . . . . . . . . . . . . . . . . . . . . . . 80
Step 10. Use sets and maps . . . . . . . . . . . . . . . . . . . 81
Step 11. Learn to recognize the functional style . . . . . . . . 86
Step 12. Read lines from a file . . . . . . . . . . . . . . . . . 89
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

4 Classes and Objects 93


4.1 Classes, fields, and methods . . . . . . . . . . . . . . . 93
4.2 Semicolon inference . . . . . . . . . . . . . . . . . . . 98
4.3 Singleton objects . . . . . . . . . . . . . . . . . . . . . 99
4.4 A Scala application . . . . . . . . . . . . . . . . . . . 102
4.5 The Application trait . . . . . . . . . . . . . . . . . . 105
4.6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 106

5 Basic Types and Operations 107


5.1 Some basic types . . . . . . . . . . . . . . . . . . . . . 107
5.2 Literals . . . . . . . . . . . . . . . . . . . . . . . . . . 108
5.3 Operators are methods . . . . . . . . . . . . . . . . . . 115
5.4 Arithmetic operations . . . . . . . . . . . . . . . . . . 118
5.5 Relational and logical operations . . . . . . . . . . . . 119
5.6 Bitwise operations . . . . . . . . . . . . . . . . . . . . 121
5.7 Object equality . . . . . . . . . . . . . . . . . . . . . . 123
5.8 Operator precedence and associativity . . . . . . . . . . 124
5.9 Rich wrappers . . . . . . . . . . . . . . . . . . . . . . 127
5.10 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 127

6 Functional Objects 129


6.1 A specification for class Rational . . . . . . . . . . . 129
6.2 Constructing a Rational . . . . . . . . . . . . . . . . 130
6.3 Reimplementing the toString method . . . . . . . . . 132
6.4 Checking preconditions . . . . . . . . . . . . . . . . . 133
6.5 Adding fields . . . . . . . . . . . . . . . . . . . . . . . 133
6.6 Self references . . . . . . . . . . . . . . . . . . . . . . 135
6.7 Auxiliary constructors . . . . . . . . . . . . . . . . . . 136
6.8 Private fields and methods . . . . . . . . . . . . . . . . 138

Cover · Overview · Contents · Discuss · Suggest · Glossary · Index


Contents ix

6.9 Defining operators . . . . . . . . . . . . . . . . . . . . 139


6.10 Identifiers in Scala . . . . . . . . . . . . . . . . . . . . 141
6.11 Method overloading . . . . . . . . . . . . . . . . . . . 144
6.12 Implicit conversions . . . . . . . . . . . . . . . . . . . 146
6.13 A word of caution . . . . . . . . . . . . . . . . . . . . 147
6.14 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 147

7 Built-in Control Structures 149


7.1 If expressions . . . . . . . . . . . . . . . . . . . . . . 150
7.2 While loops . . . . . . . . . . . . . . . . . . . . . . . 151
7.3 For expressions . . . . . . . . . . . . . . . . . . . . . . 154
7.4 Exception handling with try expressions . . . . . . . . 159
7.5 Match expressions . . . . . . . . . . . . . . . . . . . . 163
7.6 Living without break and continue . . . . . . . . . . 165
7.7 Variable scope . . . . . . . . . . . . . . . . . . . . . . 167
7.8 Refactoring imperative-style code . . . . . . . . . . . . 170
7.9 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 172

8 Functions and Closures 173


8.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . 173
8.2 Local functions . . . . . . . . . . . . . . . . . . . . . . 175
8.3 First-class functions . . . . . . . . . . . . . . . . . . . 177
8.4 Short forms of function literals . . . . . . . . . . . . . 179
8.5 Placeholder syntax . . . . . . . . . . . . . . . . . . . . 180
8.6 Partially applied functions . . . . . . . . . . . . . . . . 181
8.7 Closures . . . . . . . . . . . . . . . . . . . . . . . . . 184
8.8 Repeated parameters . . . . . . . . . . . . . . . . . . . 188
8.9 Tail recursion . . . . . . . . . . . . . . . . . . . . . . . 189
8.10 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 193

9 Control Abstraction 194


9.1 Reducing code duplication . . . . . . . . . . . . . . . . 194
9.2 Simplifying client code . . . . . . . . . . . . . . . . . 198
9.3 Currying . . . . . . . . . . . . . . . . . . . . . . . . . 200
9.4 Writing new control structures . . . . . . . . . . . . . . 202
9.5 By-name parameters . . . . . . . . . . . . . . . . . . . 205
9.6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 208

Cover · Overview · Contents · Discuss · Suggest · Glossary · Index


Contents x

10 Composition and Inheritance 209


10.1 A two-dimensional layout library . . . . . . . . . . . . 209
10.2 Abstract classes . . . . . . . . . . . . . . . . . . . . . 210
10.3 Defining parameterless methods . . . . . . . . . . . . . 211
10.4 Extending classes . . . . . . . . . . . . . . . . . . . . 214
10.5 Overriding methods and fields . . . . . . . . . . . . . . 216
10.6 Defining parametric fields . . . . . . . . . . . . . . . . 217
10.7 Invoking superclass constructors . . . . . . . . . . . . . 219
10.8 Using override modifiers . . . . . . . . . . . . . . . . 220
10.9 Polymorphism and dynamic binding . . . . . . . . . . 222
10.10 Declaring final members . . . . . . . . . . . . . . . . . 224
10.11 Using composition and inheritance . . . . . . . . . . . 226
10.12 Implementing above, beside, and toString . . . . . . 227
10.13 Defining a factory object . . . . . . . . . . . . . . . . . 229
10.14 Heighten and widen . . . . . . . . . . . . . . . . . . . 231
10.15 Putting it all together . . . . . . . . . . . . . . . . . . . 235
10.16 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 236

11 Scala’s Hierarchy 237


11.1 Scala’s class hierarchy . . . . . . . . . . . . . . . . . . 237
11.2 How primitives are implemented . . . . . . . . . . . . 241
11.3 Bottom types . . . . . . . . . . . . . . . . . . . . . . . 243
11.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 244

12 Traits 245
12.1 How traits work . . . . . . . . . . . . . . . . . . . . . 245
12.2 Thin versus rich interfaces . . . . . . . . . . . . . . . . 248
12.3 Example: Rectangular objects . . . . . . . . . . . . . . 249
12.4 The Ordered trait . . . . . . . . . . . . . . . . . . . . 252
12.5 Traits as stackable modifications . . . . . . . . . . . . . 254
12.6 Why not multiple inheritance? . . . . . . . . . . . . . . 258
12.7 To trait, or not to trait? . . . . . . . . . . . . . . . . . . 262
12.8 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 263

13 Packages and Imports 264


13.1 Packages . . . . . . . . . . . . . . . . . . . . . . . . . 264
13.2 Imports . . . . . . . . . . . . . . . . . . . . . . . . . . 268
13.3 Implicit imports . . . . . . . . . . . . . . . . . . . . . 272

Cover · Overview · Contents · Discuss · Suggest · Glossary · Index


Contents xi

13.4 Access modifiers . . . . . . . . . . . . . . . . . . . . . 273


13.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 278

14 Assertions and Unit Testing 279


14.1 Assertions . . . . . . . . . . . . . . . . . . . . . . . . 279
14.2 Unit testing in Scala . . . . . . . . . . . . . . . . . . . 281
14.3 Informative failure reports . . . . . . . . . . . . . . . . 282
14.4 Using JUnit and TestNG . . . . . . . . . . . . . . . . . 284
14.5 Tests as specifications . . . . . . . . . . . . . . . . . . 286
14.6 Property-based testing . . . . . . . . . . . . . . . . . . 288
14.7 Organizing and running tests . . . . . . . . . . . . . . 290
14.8 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 292

15 Case Classes and Pattern Matching 293


15.1 A simple example . . . . . . . . . . . . . . . . . . . . 293
15.2 Kinds of patterns . . . . . . . . . . . . . . . . . . . . . 298
15.3 Pattern guards . . . . . . . . . . . . . . . . . . . . . . 307
15.4 Pattern overlaps . . . . . . . . . . . . . . . . . . . . . 309
15.5 Sealed classes . . . . . . . . . . . . . . . . . . . . . . 310
15.6 The Option type . . . . . . . . . . . . . . . . . . . . . 312
15.7 Patterns everywhere . . . . . . . . . . . . . . . . . . . 314
15.8 A larger example . . . . . . . . . . . . . . . . . . . . . 318
15.9 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 326

16 Working with Lists 327


16.1 List literals . . . . . . . . . . . . . . . . . . . . . . . . 327
16.2 The List type . . . . . . . . . . . . . . . . . . . . . . 328
16.3 Constructing lists . . . . . . . . . . . . . . . . . . . . . 328
16.4 Basic operations on lists . . . . . . . . . . . . . . . . . 329
16.5 List patterns . . . . . . . . . . . . . . . . . . . . . . . 330
16.6 First-order methods on class List . . . . . . . . . . . . 332
16.7 Higher-order methods on class List . . . . . . . . . . 343
16.8 Methods of the List object . . . . . . . . . . . . . . . 351
16.9 Understanding Scala’s type inference algorithm . . . . . 355
16.10 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 358

17 Collections 359
17.1 Overview of the library . . . . . . . . . . . . . . . . . 359

Cover · Overview · Contents · Discuss · Suggest · Glossary · Index


Contents xii

17.2 Sequences . . . . . . . . . . . . . . . . . . . . . . . . 361


17.3 Sets and maps . . . . . . . . . . . . . . . . . . . . . . 367
17.4 Selecting mutable versus immutable collections . . . . 377
17.5 Initializing collections . . . . . . . . . . . . . . . . . . 380
17.6 Tuples . . . . . . . . . . . . . . . . . . . . . . . . . . 383
17.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 386

18 Stateful Objects 387


18.1 What makes an object stateful? . . . . . . . . . . . . . 387
18.2 Reassignable variables and properties . . . . . . . . . . 390
18.3 Case study: Discrete event simulation . . . . . . . . . . 393
18.4 A language for digital circuits . . . . . . . . . . . . . . 394
18.5 The Simulation API . . . . . . . . . . . . . . . . . . 397
18.6 Circuit Simulation . . . . . . . . . . . . . . . . . . . . 401
18.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 409

19 Type Parameterization 410


19.1 Functional queues . . . . . . . . . . . . . . . . . . . . 410
19.2 Information hiding . . . . . . . . . . . . . . . . . . . . 414
19.3 Variance annotations . . . . . . . . . . . . . . . . . . . 417
19.4 Checking variance annotations . . . . . . . . . . . . . . 421
19.5 Lower bounds . . . . . . . . . . . . . . . . . . . . . . 424
19.6 Contravariance . . . . . . . . . . . . . . . . . . . . . . 426
19.7 Object private data . . . . . . . . . . . . . . . . . . . . 429
19.8 Upper bounds . . . . . . . . . . . . . . . . . . . . . . 431
19.9 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 434

20 Abstract Members 435


20.1 A quick tour of abstract members . . . . . . . . . . . . 435
20.2 Type members . . . . . . . . . . . . . . . . . . . . . . 436
20.3 Abstract vals . . . . . . . . . . . . . . . . . . . . . . . 437
20.4 Abstract vars . . . . . . . . . . . . . . . . . . . . . . . 438
20.5 Initializing abstract vals . . . . . . . . . . . . . . . . . 439
20.6 Abstract types . . . . . . . . . . . . . . . . . . . . . . 447
20.7 Path-dependent types . . . . . . . . . . . . . . . . . . 449
20.8 Enumerations . . . . . . . . . . . . . . . . . . . . . . . 452
20.9 Case study: Currencies . . . . . . . . . . . . . . . . . . 454
20.10 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 463

Cover · Overview · Contents · Discuss · Suggest · Glossary · Index


Contents xiii

21 Implicit Conversions and Parameters 465


21.1 Implicit conversions . . . . . . . . . . . . . . . . . . . 465
21.2 Rules for implicits . . . . . . . . . . . . . . . . . . . . 468
21.3 Implicit conversion to an expected type . . . . . . . . . 471
21.4 Converting the receiver . . . . . . . . . . . . . . . . . 473
21.5 Implicit parameters . . . . . . . . . . . . . . . . . . . . 475
21.6 View bounds . . . . . . . . . . . . . . . . . . . . . . . 481
21.7 Debugging implicits . . . . . . . . . . . . . . . . . . . 485
21.8 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 486

22 Implementing Lists 487


22.1 The List class in principle . . . . . . . . . . . . . . . 487
22.2 The ListBuffer class . . . . . . . . . . . . . . . . . . 493
22.3 The List class in practice . . . . . . . . . . . . . . . . 495
22.4 Functional on the outside . . . . . . . . . . . . . . . . 497
22.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 498

23 For Expressions Revisited 500


23.1 For expressions . . . . . . . . . . . . . . . . . . . . . . 501
23.2 The n-queens problem . . . . . . . . . . . . . . . . . . 503
23.3 Querying with for expressions . . . . . . . . . . . . . 506
23.4 Translation of for expressions . . . . . . . . . . . . . . 508
23.5 Going the other way . . . . . . . . . . . . . . . . . . . 512
23.6 Generalizing for . . . . . . . . . . . . . . . . . . . . . 513
23.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 515

24 Extractors 516
24.1 An example: Extracting email addresses . . . . . . . . 516
24.2 Extractors . . . . . . . . . . . . . . . . . . . . . . . . 517
24.3 Patterns with zero or one variables . . . . . . . . . . . 520
24.4 Variable argument extractors . . . . . . . . . . . . . . . 522
24.5 Extractors and sequence patterns . . . . . . . . . . . . 525
24.6 Extractors versus case classes . . . . . . . . . . . . . . 526
24.7 Regular expressions . . . . . . . . . . . . . . . . . . . 527
24.8 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 531

25 Annotations 532
25.1 Why have annotations? . . . . . . . . . . . . . . . . . 532

Cover · Overview · Contents · Discuss · Suggest · Glossary · Index


Contents xiv

25.2 Syntax of annotations . . . . . . . . . . . . . . . . . . 533


25.3 Standard annotations . . . . . . . . . . . . . . . . . . . 535
25.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 537

26 Working with XML 539


26.1 Semi-structured data . . . . . . . . . . . . . . . . . . . 539
26.2 XML overview . . . . . . . . . . . . . . . . . . . . . . 540
26.3 XML literals . . . . . . . . . . . . . . . . . . . . . . . 541
26.4 Serialization . . . . . . . . . . . . . . . . . . . . . . . 543
26.5 Taking XML apart . . . . . . . . . . . . . . . . . . . . 545
26.6 Deserialization . . . . . . . . . . . . . . . . . . . . . . 546
26.7 Loading and saving . . . . . . . . . . . . . . . . . . . 547
26.8 Pattern matching on XML . . . . . . . . . . . . . . . . 549
26.9 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 552

27 Modular Programming Using Objects 553


27.1 The problem . . . . . . . . . . . . . . . . . . . . . . . 554
27.2 A recipe application . . . . . . . . . . . . . . . . . . . 555
27.3 Abstraction . . . . . . . . . . . . . . . . . . . . . . . . 558
27.4 Splitting modules into traits . . . . . . . . . . . . . . . 561
27.5 Runtime linking . . . . . . . . . . . . . . . . . . . . . 564
27.6 Tracking module instances . . . . . . . . . . . . . . . . 565
27.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 567

28 Object Equality 568


28.1 Equality in Scala . . . . . . . . . . . . . . . . . . . . . 568
28.2 Writing an equality method . . . . . . . . . . . . . . . 569
28.3 Defining equality for parameterized types . . . . . . . . 582
28.4 Recipes for equals and hashCode . . . . . . . . . . . 587
28.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 593

29 Combining Scala and Java 594


29.1 Using Scala from Java . . . . . . . . . . . . . . . . . . 594
29.2 Annotations . . . . . . . . . . . . . . . . . . . . . . . 597
29.3 Existential types . . . . . . . . . . . . . . . . . . . . . 602
29.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 606

30 Actors and Concurrency 607

Cover · Overview · Contents · Discuss · Suggest · Glossary · Index


Contents xv

30.1 Trouble in paradise . . . . . . . . . . . . . . . . . . . . 607


30.2 Actors and message passing . . . . . . . . . . . . . . . 608
30.3 Treating native threads as actors . . . . . . . . . . . . . 612
30.4 Better performance through thread reuse . . . . . . . . 613
30.5 Good actors style . . . . . . . . . . . . . . . . . . . . . 616
30.6 A longer example: Parallel discrete event simulation . . 623
30.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 640

31 Combinator Parsing 642


31.1 Example: Arithmetic expressions . . . . . . . . . . . . 643
31.2 Running your parser . . . . . . . . . . . . . . . . . . . 645
31.3 Basic regular expression parsers . . . . . . . . . . . . . 646
31.4 Another example: JSON . . . . . . . . . . . . . . . . . 647
31.5 Parser output . . . . . . . . . . . . . . . . . . . . . . . 649
31.6 Implementing combinator parsers . . . . . . . . . . . . 655
31.7 String literals and regular expressions . . . . . . . . . . 664
31.8 Lexing and parsing . . . . . . . . . . . . . . . . . . . . 665
31.9 Error reporting . . . . . . . . . . . . . . . . . . . . . . 665
31.10 Backtracking versus LL(1) . . . . . . . . . . . . . . . . 667
31.11 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 669

32 GUI Programming 671


32.1 A first Swing application . . . . . . . . . . . . . . . . . 671
32.2 Panels and layouts . . . . . . . . . . . . . . . . . . . . 674
32.3 Handling events . . . . . . . . . . . . . . . . . . . . . 676
32.4 Example: Celsius/Fahrenheit converter . . . . . . . . . 679
32.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 681

33 The SCells Spreadsheet 683


33.1 The visual framework . . . . . . . . . . . . . . . . . . 683
33.2 Disconnecting data entry and display . . . . . . . . . . 686
33.3 Formulas . . . . . . . . . . . . . . . . . . . . . . . . . 689
33.4 Parsing formulas . . . . . . . . . . . . . . . . . . . . . 691
33.5 Evaluation . . . . . . . . . . . . . . . . . . . . . . . . 696
33.6 Operation libraries . . . . . . . . . . . . . . . . . . . . 699
33.7 Change propagation . . . . . . . . . . . . . . . . . . . 702
33.8 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . 706

Cover · Overview · Contents · Discuss · Suggest · Glossary · Index


Contents xvi

A Scala scripts on Unix and Windows 708

Glossary 709

Bibliography 725

About the Authors 728

Index 729

Cover · Overview · Contents · Discuss · Suggest · Glossary · Index


List of Figures

2.1 The basic form of a function definition in Scala. . . . . . . . 63


2.2 The syntax of a function literal in Scala. . . . . . . . . . . . 69

3.1 All operations are method calls in Scala. . . . . . . . . . . . 74


3.2 Class hierarchy for Scala sets. . . . . . . . . . . . . . . . . 82
3.3 Class hierarchy for Scala maps. . . . . . . . . . . . . . . . . 84

10.1 Class diagram for ArrayElement. . . . . . . . . . . . . . . 215


10.2 Class diagram for LineElement. . . . . . . . . . . . . . . . 220
10.3 Class hierarchy of layout elements . . . . . . . . . . . . . . 223
10.4 Class hierarchy with revised LineElement. . . . . . . . . . 227

11.1 Class hierarchy of Scala. . . . . . . . . . . . . . . . . . . . 239

12.1 Inheritance hierarchy and linearization of class Cat. . . . . . 261

14.1 ScalaTest’s graphical reporter. . . . . . . . . . . . . . . . . 291

17.1 Class hierarchy for Scala collections. . . . . . . . . . . . . . 360


17.2 Class hierarchy for Iterator. . . . . . . . . . . . . . . . . 361

18.1 Basic gates. . . . . . . . . . . . . . . . . . . . . . . . . . . 394


18.2 A half-adder circuit. . . . . . . . . . . . . . . . . . . . . . . 396
18.3 A full-adder circuit. . . . . . . . . . . . . . . . . . . . . . . 397

19.1 Covariance and contravariance in function type parameters. . 429

22.1 Class hierarchy for Scala lists. . . . . . . . . . . . . . . . . 488


22.2 The structure of the Scala lists shown in Listing 22.2. . . . . 492

xvii
List of Figures xviii

32.1 A simple Swing application: initial (left) and resized (right). 672
32.2 A reactive Swing application: initial (left) after clicks (right). 674
32.3 A converter between degrees Celsius and Fahrenheit. . . . . 679

33.1 A simple spreadsheet table. . . . . . . . . . . . . . . . . . . 684


33.2 Cells displaying themselves. . . . . . . . . . . . . . . . . . 689
33.3 Cells displaying their formulas. . . . . . . . . . . . . . . . . 695
33.4 Cells that evaluate. . . . . . . . . . . . . . . . . . . . . . . 701

Cover · Overview · Contents · Discuss · Suggest · Glossary · Index


List of Tables

3.1 Some List methods and usages . . . . . . . . . . . . . . . 78

5.1 Some basic types . . . . . . . . . . . . . . . . . . . . . . . 108


5.2 Special character literal escape sequences . . . . . . . . . . 112
5.3 Operator precedence . . . . . . . . . . . . . . . . . . . . . 126
5.4 Some rich operations . . . . . . . . . . . . . . . . . . . . . 128
5.5 Rich wrapper classes . . . . . . . . . . . . . . . . . . . . . 128

12.1 Linearization of types in Cat’s hierarchy . . . . . . . . . . . 262

13.1 Effects of private qualifiers on LegOfJourney.distance . . 276

16.1 Basic list operations . . . . . . . . . . . . . . . . . . . . . . 330

17.1 Common operations for sets . . . . . . . . . . . . . . . . . 370


17.2 Common operations for maps . . . . . . . . . . . . . . . . . 372
17.3 Default immutable set implementations . . . . . . . . . . . 374
17.4 Default immutable map implementations . . . . . . . . . . . 374

31.1 Summary of parser combinators . . . . . . . . . . . . . . . 653

xix
List of Listings

3.1 Parameterizing an array with a type. . . . . . . . . . . . . 72


3.2 Creating and initializing an array. . . . . . . . . . . . . . . 75
3.3 Creating and initializing a list. . . . . . . . . . . . . . . . . 76
3.4 Creating and using a tuple. . . . . . . . . . . . . . . . . . 80
3.5 Creating, initializing, and using an immutable set. . . . . . 81
3.6 Creating, initializing, and using a mutable set. . . . . . . . 83
3.7 Creating, initializing, and using a mutable map. . . . . . . 84
3.8 Creating, initializing, and using an immutable map. . . . . 85
3.9 A function without side effects or vars. . . . . . . . . . . . 87
3.10 Reading lines from a file. . . . . . . . . . . . . . . . . . . 89
3.11 Printing formatted character counts for the lines of a file. . 92

4.1 Final version of class ChecksumAccumulator. . . . . . . . 97


4.2 Companion object for class ChecksumAccumulator. . . . . 100
4.3 The Summer application. . . . . . . . . . . . . . . . . . . . 102
4.4 Using the Application trait. . . . . . . . . . . . . . . . . 105

6.1 Rational with fields. . . . . . . . . . . . . . . . . . . . . 135


6.2 Rational with an auxiliary constructor. . . . . . . . . . . 137
6.3 Rational with a private field and method. . . . . . . . . . 138
6.4 Rational with operator methods. . . . . . . . . . . . . . . 140
6.5 Rational with overloaded methods. . . . . . . . . . . . . 145

7.1 Scala’s idiom for conditional initialization. . . . . . . . . . 150


7.2 Calculating greatest common divisor with a while loop. . . 151
7.3 Reading from the standard input with do-while. . . . . . . 152
7.4 Calculating greatest common divisor with recursion. . . . . 153
7.5 Listing files in a directory with a for expression. . . . . . . 154

xx
Discovering Diverse Content Through
Random Scribd Documents
Ghika, a prince of Valachia, who formed an insurrection against the Turks,
83.
Giamobasy, a village in Ionia near mount Alymán, 21, 31.
Glychensberg General, governor of the forces at Cronstadt, 87.
Goetze Dr. his manuscripts, etc., 143.
Gold, remarkable accounts of its lodging in vines and grapes in some
parts of Transylvania, and upon mount Tokaí in Hungary, 103.
Golden bull, containing the constitutions of the empire by Charles the
fourth, 119.
Gothic character, an account of it, 143.
Gouda, a town in Holland, 166.
Grabe Ern. Mr. Le Clerc’s complaint of him, 167.
Graevivs Mr. keeper of the public library at Leipsick, 141.
Grand Signior, his manner of receiving ambassadors, 66.
His person described, and manner of riding to a mosque, 69.
His titles, 70.
Grand Vizír, chief counsellor or representative of the Grand Signior, his
manner of giving audience to ambassadors, 65.
His person described, ib.
Entertains the L. Paget, 70.
As to the inferior visírs, his assistants, see Wilson’s Seraglio, p. 610,
611.
Granicvs, see Boclew.
Graven Lieut. Col., 87.
Receives a present of a diamond ring from L. Paget, 91.
Greeks, their church at St. George’s, 3.
Their devotion, 4.
Manner of celebrating the Eucharist, ib.
Churches at Tyria, 20.
They abhor all imagery in releivo, 20, 61.
Their funerals, 39.
Famous convent called Maurómolos, 42.
Numerous chapels about the town Milo, 176.
Guns, see Eski Natolia Hisar.
Gygaean lake, near Sardis, 17.
Gyongyossi, a city in Hungary taken from the Protestants by the Jesuits,
108.
Gyongyossi Paul, a Hungarian divine, who formerly resided at Oxford, 106.

H.
Habern, a wood in Bohemia, 133.
Hadgelar, a village near Smyrna, so called from its being the first
rendevous of the hadjées or pilgrims in their annual journey from
Smyrna to Mecca, 55.
Inscriptions there, ib.
Haemvs, a mountain in Thrace, 74.
Hague, a town in Holland, 162.
Prince of Orange’s house in the adjacent wood, 164.
Halberstadt, a town in Saxony, 146.
Halesvs, a river in Ionia, discharging itself into the sea at Colophon, 31.
Hall, a city of Suabia described, with the university, 145.
Hamal, a Turkish name for a boatman or porter. In the modern Greek
χαμάλ, 39.
Hamburg, a free Imperial city, and chief of the Hanse towns, seated on the
north side of the Elbe, 152.
Besieged in 1686 by the king of Denmark, 153.
The religion, government, dress, funerals, and trade of the
inhabitants, with the English company of merchants there, ibid.
Famous for Rhenish wine and fine loaf sugar, 156.
An account of the opera house, and a model of Solomon’s temple,
157.
The language and manners of the inhabitants, 158.
The detestable practice of melancholy persons, and infamous
character of a monstrous virago there, ib.
Hanover, the chief city of that electorate, described, 151.
An account of the Electoral family, ib.
Harach, a pole tax laid upon Christians by the Turks, 42.
Harburg, a town in Lunenburg, 152.
Harda, a river running into the Hebrus at Adrianople, 63.
Harem, a Turkish word for women, or the womens apartment, 32, 38.
In the Arabic language it signifies things forbidden.
Harlem, a town in Holland, which claims the invention of printing, 167.
Hasanogli, the mosque at Magnesia, where he was buried, held in great
veneration by the Turks, 11.
Hase, a river in Westphalia. 161.
Haselun, a town in Westphalia, ib.
Hatwan, a town in Hungary, 109.
Hebrvs, a famous river of Thrace, 62.
Hellespont, now called the Dardanells, flows perpetually into the Aegean
sea, 35.
Its breadth, 61.
Hens of Grand Cairo described, 46.
Heraclea, a city of Thrace, 38.
Hermannvs, founder of Hermanstadt, his statue there, 92.
Hermanstadt, a city in Transylvania, L. Paget’s entertainment there, 90.
Inscriptions there, 91.
Its government, 92.
Hermvs, a famous river in Ionia described, 5, 56.
Hessen, a small village in Saxony, the Duke of Brunswick’s house there,
146.
Heusler, General, defeated and taken by Count Tekely near Rosnaw in
Transylvania, 87.
Hildesheim, a city of Lower Saxony, 146.
Hippivs, a river near the city Prusia, 51.
Hogia, a Turkish word signifying a learned man, an instructor, or teacher,
69.
Holibrun, a town in Austria, 131.
Holthenvs Edvardus, a learned divine of Utrecht, who was then publishing
the new edition of Gruter, 169.
Holy Sepulcher, certain rents at Bucurest in Valachia consigned for the use
of it, 80.
Homer, an old manuscript of him in the university library at Leipsick, 143.
Honslardyke, a palace of K. William near the Hague, 166.
Horse tails, two allowed by the Turks to be carried before the prince of
Valachia, 81.
Host, see De Barias Didacus.
Hound slayer, his office at Baden, 128.
Hour in traveling, about three English miles, 5.
See Dr. Shaw’s Preface to his Travels, p. ix.
Houses in Hungary made under ground, 108.
Hu, Hu, that is, he be, or he who is; with the Turks meaning God, 71.
See D’Herbelot, and Wilson’s Seraglio, p. 764, 786.
Humumlee, a village in Mysia Minor near the lake Minyás, 59.
Hungari, a people of Transylvania, 99.
Their government, 100.
Religion, 101.
Customs, 104.
Hungars, a gold coin in Turkey, worth about ten shillings sterling, 39.
Hungary, divided from Transylvania near the village Zilak, 98.
Its soil rich and abounding with lakes, 111.
Divided from Austria by the river Leyta, 114.
Hungrisch Altenburg, a town in Hungary, situated on the river Leyta, 114.
Hvnni, a colony of Scythians, now settled in Transylvania, 99, 100.
Hyaena, one at Neugebac in Austria described, 118.
Hyllvs, a river near Thyatira, 52.

I.
Jacacui, a village near Smyrna, 2.
Jalomitza, a river in Valachia, 83.
Janikaw, a town in Bohemia, memorable for the battle in 1645 between
the Swedes and Imperialists, 133.
Janisaries, a body of the Turkish infantry. The word signifies new soldiers,
as they were the last order introduced. They make the Grand
Signior’s foot guard, and the spaheés the horse, 2.
The manner of their dismission from duty, 68.
Ichoglans, youth born of Christian parents, and educated by the Turks in
the seraglio for public offices of the state, 46.
Ida, now Cordág, a mountain near Troy, 33, 58, 59, 60.
Jenicui, a town in Thrace, 73.
Jerdack, a village in Mysia Minor near Lampsacus, 60.
Two inscriptions there, ib.
Jesuits, their convents at Vienna, 117.
And colleges at Prague, 135.
Where they have the direction of the university and public schools,
137.
Pictures in St. Nicholas’s college at Messina in honour of those five,
who were executed in England for the popish plot, 174.
Jews at Pernitz, their mark of distinction, 132.
and at Prague, 137.
Iglaw, a city in Moravia, 132.
Houses there with false fronts, ib.
Iglaw, a river in Moravia, 132.
Igmand, a town in Hungary, 112.
Iirid, a Turkish javelin. The modern Greeks write it τζιρήδ. 46.
Ilfof, a small river in Valachia, 82.
Ilivm, see Troy.
Images, see Statues.
Imam, a Turkish priest, who daily says public prayers. From the Greek
word ἐφημέριος, by the modern Greeks corrupted into ἡμάμ, 60.
Imbros, an island in the Aegean sea, near the Chersonésos, 33.
Inn, see Arnswoldt.
Inscriptions Greek, one at Magnesia, 11.
At Durguthli, 14.
At Tyria, 20.
Three at Ephesus, 28, 29.
One at Constantinople, 41.
At the convent Maurómolos, 42.
Upon Aurátbasar’s pillar at Constantinople, 44.
On a tower near Porto Janicula, 48.
Others near the seraglio, 49.
One at Prusia, 51.
Others at Thyatira, 53, 56, 57.
At Hadgelar, 55.
And at Jerdáck, 60.
One at Komora, 112.
Another belonging to Mr. Neufville at Leyden, 165.
And another to Mr. Uilenbroek at Amsterdam, 168.
Inscriptions Latin, one at Ephesus, 25.
At Constantinople, 41.
Upon one of the Symplegades, 42.
Two in the great seraglio at Constantinople, 46.
Others at Hadgelar, 55.
And at Thyatira, 57.
Three at Hermanstadt, 91.
And at Wissenburg, 95.
One at Therda, 96.
Two at Clausenburg, 97.
And at Komora, 112.
One at Petronel, 125.
Another belonging to Mr. Cuper at Deventer, 162.
Others to Mr. Neufville at Leyden, 164.
And one to Mr. Uilenbroek at Amsterdam, 168.
John Saint, his church at Ephesus, 24.
And hospital at Cadiz, 171.
Irongate, a place so called in Mysia Minor, 52.
Ishmaelja, a village in Ionia near Durguthli, 14.
Isvora, a pleasant place incompassed with woods in Valachia, near the
river Dembowitza, 83.
Jvstvs Sanctus, his bones carried in procession at Vienna, 124.

K.
Kanes, public places in Turkey, both on the road and in towns, with a
mosque usually in the middle, enclosed for the lodging of travellers,
8, 13, 80.
See Maundrell, pag. 1.
These buildings seem to have been very antient in the East, and
alluded to Jerem. ix. 2. where by the Septuagint they are called
σταθμοί.
Kaposi Samuel, professor of the Schola Albensis at Wissenburg, teaches
the English language to the students, 94.
καστριωτης Κῦρ Γεώργιος, a Grecian at Bucurest in Valachia, 80.
Kaya, a deputy of the grand vizír, 65.
Kerepes, a town in Hungary, 109.
Kible, or Kiblah, that part in a Turkish mosque, whose prospect is towards
Mecca, to which they always turn, when they pray, 8.
See Dr. Shaw’s Travels, p. 284.
Kief, a Turkish word, signifying delight or pleasure, 10.
King of France, an epigram upon him by the Emperor, 120.
King of Poland, his dexterity in shooting, 125.
Kiosk, a Turkish pleasure house, 6.
Kirkingecui, a Christian village near Ephesus, 21, 22.
Klopperburg, a town in the bishopric of Munster, 161.
Koendern, a town in Upper Saxony, 146.
Koes Johannes, professor of divinity at Debrecyn in Hungary, 106.
Koes, a town in Hungary remarkable for the many curious trees, herbs,
and flowers, which grow near it, 111.
Koloseri Samuel, inspector general of the emperor’s mines in
Transylvania, 93.
Kolosvari Stephanus, professor of philosophy at Enyed, 95.
Komora, a city in Hungary, 112.
Inscriptions in the castle, ib.
Koningsmark Count, brass statues of the twelve Apostles at Prague
converted by him into canon, 136.
Koolaert Mr. merchant of Harlem an account of his daughter, who was
born deaf, being taught to speak, 167.
Kottin, a town in Bohemia, 133.
Krasna, a river in Hungary, 98.
Kremnytz, a town in Hungary, famous for mines of gold and other metals,
109.
Kunstcammer, or arts chamber, the Elector of Saxony’s repository of rarities
at Dresden so called, 140.
κυριακοδρομιον, see Maximus Hieromonac.
Kurugelchick, or the dried lake a village on mount Temnus in Mysia Major,
57.
Kutali, a small island in the Propontis near Marmora, 37.
Kuttenberg, a city in Bohemia, 133.
Kysler aga, the chief eunuch so called by the Turks, 69.

L.
Lambecivs, keeper of the Imperial library at Vienna, turned Papist in order
to qualify himself for that imployment, 121.
Lampsacvs, a town in Mysia Minor, 37, 60.
Landaw, a city of Alsace, 122.
Langerman Mr. a druggist at Hamburg, his curiosities, 157.
Lapis Lydivs, so called from Lydia, a country in Asia Minor, 10.
Latin Letters in ms. writen by the present emperor to Lambecius, in the
Imperial library at Vienna, 120.
Launa, a town in Bohemia, 138.
Lectionarivm of the four Evangelists at Kirkingécui near Ephesus, 22.
Lecton, see Baba.
Leewenhoek Mr. his curious discoveries upon insects, etc., 165.
Leibnitz Mr. librarian to the Duke of Brunswick at Wolfembutel, 147.
Leichtenstein Prince, purchased the bones of three Hungarian Saints in
Italy, and conveyed them to Vienna, 124.
Leine, a river in the Electorate of Hanover, 151.
Leipsick, a city in Upper Saxony described, 140.
Its government, 141.
Commodities, university, etc., 142, 144.
The habit of the ecclesiastics, 145.
Lemnos, an island in the Aegean sea, 33.
Leo the Emperor, his superstition, 45.
Leopards at the palace of Neugebac, near Vienna, described, 118.
Leopold Saint, a castle on the Danube, near Cloyster Newburg in Austria,
131.
Lepelar, a sort of stork, 166.
Lesbos, see Mitylene.
Leyden, a city in Holland, 162.
Leyta, a river in Hungary, 114.
Libraries.
Windhagiana and Imperial at Vienna, 119.
Premonstratensian at Prague, 136.
The Duke of Brunswick’s at Wolfembutel, 147.
Those at Leipsick, 143.
And Hamburg, 157.
Licinnivs, see Constantine.
λιμνη δασκυλιτις, a lake in Mysia Minor, now called Minyás, 58.
Lingen, a town in Westphalia, described, 161.
Lion dollars, coins current in Valachia, 85.
Livy, an account of an antient manuscript, which seems to have contained
more books of that author, than the present copies, 119.
Loaf sugar, see Hamburg.
Loo in Gelderland, K. William’s house and gardens there, 162, 169.
Lubeck, an Hanse town in Lower Saxony, 157.
Luther, a picture of him at Leipsick taken after his death, 143.
Reliques of his in the Duke’s library at Wolfembutel, 148.
Lutherans, their churches and manner of worship in Transylvania
described, 101, 102.
Their manner of communicating, 144, 147.
Luxemburg near Vienna, an Imperial palace there, 117.
The castle described, with a remarkable instance of thunder, which
happened in it, 126.
Lynces, at the palace of Neugebac near Vienna described, 118.

M.
Mackshusen, a town in Overissel, 162.
Madonna, see Mary.
Magnesia ad Sipylum, city of Lydia, 5, 56.
Its manufacture, 6.
A seraglio, madhouse, college of dervíses, and royal mosques there
described, 7, 8.
Gave name to the magnet, 9.
Inscriptions there, 11.
Magnet, see Magnesia.
Mahomet effendi, his courtesy to the travelers at Magnesia, 6.
Mahomet iv. Sultan, a stone bridge built by him near Dimotico in Mysia
Minor, 60.
Maitos, antiently Madytos, a town in the Chersonésus, described, 37.
Makren, see Moravia.
Malgara, a town in Thrace, described, 62.
Mamot, an East Indian animal, like a stag, with twisted horns, 166.
Mandahora, a village on the river Aesépus in Mysia Minor, described, 52,
58.
Marcomanni, see Moravia.
Margaret, Countess of Henneberg, said to have had 165 children at a
birth, 165.
Margarita, a town in Hungary, 98.
Mark, see Morawa.
Marmora, an island in the Propontis described, 37.
Marvs, see Morawa.
Mary Virgin, her pillar at Vienna described, 115.
Her picture said to have shed tears, 116.
A miraculous image of her, ib.
A new sort of Gloria Patri inscribed to her, 131.
Her statue at Prague, 134.
Picture pretended to be done by St. Luke, 135.
Numerous titles, 136, 173.
A stone sculpture of her and our Savior at Messina, beleived to have
been taken from the life, 174.
Her letter to the Messanians, 175.
Mauromolos, a Greek convent on the European side of the Bosphorus,
described, 42.
Mavrvsivs, a river near Wissenburg in Transylvania, 93.
Maximvs Hieromonachus, a famous Greek monk, author of a book called
Κυριακοδρόμιον, 80.
Meander, a river in Ionia, 5.
Medoslanivm, see Znaim.
Melancholy persons, their method to get rid of their lives at Hamburg,
158.
Melancthon, a celebrated picture of him at Leipsick, taken after his death,
143.
Melas, a river in Thrace, flowing into the gulph Cardia, 62.
Melos, see Milo.
Menchenivs Dr. Otto, professor of moral philosophy at Leipsick, and editor
of the Acta Eruditorum, 142.
Menchenivs Junior, doctor of law at Leipsick, 143.
Menologion, a Greek manuscript in the possession of Dr. Goëtze at
Leipsick, 143.
Mepomienvs, or Nepomenenvs Sanctus Joannes, a new saint at Vienna, 117.
A brazen statue and inscription erected there to his memory, 137.
Mercy, a convent at Cadiz, founded for the redemption of Christian slaves,
171.
μεσογειοτης, or Midland hills, in the Caystrian plain, 19.
Messina, a city on the coast of Sicily, described, 173.
The cathedral, monasteries, etc., 174, 175, 176.
Ceres and Proserpina antiently worshiped there, 176.
Metropolis, an antient city of Lydia, whose ruins are described, 30.
Meulevi, an order of Turkish monks, whose ceremonies are described, 49,
70.
Meyer Dr., a turbulent divine of Hamburg, 155.
Michael Saint, his church at Vienna, 117.
A remarkable picture of him at Cadiz, 171.
Mihalick, a town in Mysia Minor, where the river Aesépus discharges itself
into the sea, 58.
Mikes, Count Michael, received L. Paget on the borders of Transylvania,
86.
Mile Hungarian, equal to six Italian, 87.
Milo, antiently Melos, one of the Cyclades, with a city of the same name,
described, 176.
The birth place of Socrates and Aristophanes, ib.
Hot baths there, 177.
Minaree, a steeple, or tower, joining to a Turkish mosque, from which the
muezin, or chanter, calls the people to prayers, 7.
Mindera, a Turkish mattress, filled with cotton or wool, 67.
Ministers of the diván, their habit, 68.
Minyas, a village and castle so called in Mysia Minor, 58.
Misseltoe, its manner of growing about Thyatira, 56.
Misten, a town in Upper Saxony, 140.
Mitylene or Lesbos, an island in the Aegean sea, 32, 33.
Moesia Inferior, see Bulgaria.
Molanvs, see Gerhardvs Abbot.
Moldavia, by submitting to the Turks was taxed lower than the
neighbouring countries, 85.
Moneta bracteata, lately found in Saxony, described, 143.
Monnikedam, a town in North Holland, 168.
Montagnia, a Turkish town in Bithynia, which seems to be the Apaméa of
the antients, 50.
Monte Argentato, see Batkan.
Morat i. Emperor of the Turks, converted a Christian church at Adrianople
into a mosque, now called Eskijamí, or the Old mosque, which yet
retains the antient form, 64.
Morat Sultan, his strength and activity, 46.
Moravia, now called Makren, 131.
Antiently the seat of the Marcomanni and Quadi, 123.
The country fertile, but the people slaves, ib.
Speak the Behemish language, ib.
Morawa, antiently the Marus, a river in Austria, 131.
Called Mark by the Germans, 133.
Muezin, or chanter, who calls the Turks to their prayers, 47.
Mosques, buildings for the publick worship of the Turks, in the form of our
churches, 7.
See Dr. Shaw’s Travels, p. 283.
Mufti, the primate, or chief ecclesiastic, and of greatest authority among
the Turks; whom they are bound to consult in all causes of
importance, whether ecclesiastical, civil, or military, 69.
Mugevezee, a sort of turbant worn by the officers of the diván, 68.
Muldaw, a river, which runs thro Prague, 134.
Mulvetelee, a river near the village Minyás in Mysia Minor, 58.
Mum, see Brunswick.
Musconisia isles, situated between the continent of Aeolia and the island
of Mitylene, 33.
Muyden, a town in Holland, 169.

N.
Naerden, a town in Holland, 169.
Nakeib effendi, the chief of the sheriffs or descendants of Mahoment, 70.
Sheriff in Cantemir, p. 216, signifies an holy person.
Namaz, the common and daily prayers, which the Turks are injoined to
repeat five times in twenty four hours, 47.
ναος, the body of a Greek church, 81.
ναρθηξ, the porch of a Greek church, 81.
Natolia, or Anatolia, antiently Asia minor, 34, 35.
Nemethi M. B. professor of philosophy at Clausenburg, 97.
Neimethi Sam. professor of divinity at Clausenburg, 97.
Nepomenenvs, see Mepomienvs.
Neptune, see Statues.
Nesselivs, keeper of the Imperial library at Vienna, turned Papist in order
to qualify himself for that imployment, 121.
Nestorivs, the place where his heresy was condemned, 25.
Neufville Mr. his character, and curiosities, 164.
Neugebac, an imperial palace near Vienna, 118.
Nicholas Saint, his church at Leipsick described, 141.
And college at Messina, 174.
Niphti, or Nymphe, a river near Magnesia, some account of it, 12.
Nishangee basha, an officer, who sets the Grand Signior’s tura, or name, to
all orders sent from the Porte, 66.
See Wilson’s Seraglio, p. 610.
Nomades Scythae, see Turcmen.
Norbert Saint, patron of Bohemia, 134.
His tomb in the church of the Premonstratensians at Prague, 136.
Norlicui, a village near Smyrna, signifying the pomegranate village, 2.
The word gui, is a dissyllable, and denotes a village. Leunclav. Hist.
Turc. p. 406.
Northern, a town of the United Provinces, at the confines of Westphalia
and Overissel, 161.
Nymphe, a plain near Smyrna, 3.

O.
Ocker, a river in Lower Saxony, 147.
Oescvs Triballorvm, see Eski Stambol.
Oetingh Count, a christian church built at Challikcavák in Thrace by his
interest, 74.
Offensey, a village in Lower Saxony, 159.
Oke, a Turkish weight of about two pounds three quarters avoir de pois,
6.
See Rycaut, V. iii. p. 12.
Olearius Mr. junior, professor of humanity at Leipsick, 143.
Olympvs Mysenvs, a mountain near the city Prusia, described, 50.
Opera house, see Hamburg.
Operas, an account of those at Vienna, 122.
Orangery, see Honslardyke.
Organ, a remarkable one at Hamburg described, 154.
Orphanotrophivm at Hall, founded by Mr. Frank, 145.
Osman, see Ottoman.
Osmanogli, that is, Osman’s son, or descendant, 9.
See Leunclav. Hist. Turc. p. 418.
Ostriches, at Schonbran described, 118.
Otmarsh, a town in Overissel, 161.
Ottoman, made Prusia the first capital of the Turkish empire, 51.
Oval, a town in Bohemia, 134.
Ovid’s Metamorphoses, ms. 120.
Ovid’s Tower, a ruinous stone building not far from the Bosphorus, on the
European side, 47.

P.
Pactolvs, a river near Sart or Sardis, described, 15.
Paget Lord, ambassador from K. William to the Porte, the manner of his
audience of leave at Adrianople, 69, 70.
Entertained by the grand vizír, 70.
Presents given and received by him, 70, 71, 72, 80, 92, 96, 107,131.
His equipage and retinue, 72, 77, 78, 90, 106.
Entertained by the Prince of Valachia, 79.
His reception upon entering Transylvania, 86, 87.
At Rab, 113.
At Vienna, 115.
Audience of the King and Queen of the Romans, 131.
Paidleburg, a town in Saxony, 146.
Palaces, those of the Prince of Valachia at Bucurest and Tergovist
described, 79, 82.
Of the Emperor at or near Vienna and Prague, 117, 118, 126, 135.
Count Traun’s at Petronel, 125.
King of Poland’s at Dresden, 140.
Duke of Brunswick’s at Hessen and Wolfembutel, 146, 147.
That of the Elector of Hanover, 151.
Of the Prince of Orange in the wood near the Hague, 164.
And at Honslardyke, 166.
Palamutcui, a village near Smyrna described, 2.
Palvs Artynia, a lake fed from mount Olympus, described, 51.
παναγια, or Virgin Mother, her image described, 75.
Pannonian Alps, near Baden, in Austria, 126.
Paper, a fine sort made of silk, 69.
Curious work cut in it by a woman at Rotterdam, 165.
Pariz Papa Fr. professor of Greek at Enyed in Transylvania, 95.
Paschal colours, described, 81.
Pasha, the governor of a Turkish province, 76.
Pashacui, a village in Thrace, 73, 74.
Patriarch of Jerusalem, his residence at Bucurest in Valachia, 80.
Paul Saint, his prison, a tower at Ephesus so called, 25.
Paulins, an order of monks, who never eat flesh nor fish, 132.
Peine, a town in the dutchy of Brunswick, 149.
Pelorvs, a promontory of Sicily, 175.
Pentateuch, see Bible.
Pera, a town near Constantinople, 47.
Pergamvs, a city in Mysia Major, 52.
Pernitz, a town in Moravia, 132.
Pest, a city in Hungary, described, 109.
Peterswaldt, a town in Bohemia, 138.
Petronel, a village on the Danube, 125.
Remains of antiquity, and Count Traun’s palace there described, 125,
126.
Phocaea, see Fochia Vecchia.
Phrygivs, or Hyllvs, a river near Thyatira, 56.
Phyrites, a river between Ephesus and Smyrna, 30.
Pictures, fine ones in Luxemburg castle, 126.
At Vienna, 129, 130.
Piedra de Puerco, an account of it, 157.
Pietists in Germany, 146.
Pirn, a town in Upper Saxony, 139.
Pismetlee, a town in Mysia Minor, 60.
Plat Dutch, the language of Hamburg, a medium betwixt that of Germany
and Holland, 158.
Plebanvs, the title of the chief pastor of the Unitarians at Clausenburg in
Transylvania, 97.
Pleiss, a river in Misnia, 141.
Plica Polonica, on the head of a man at Alány in Hungary; the effects of
cutting it off, 108.
Po George, born at Prague, his strange voracity, 157.
ποδα νείατον Ἴδης, a tract of mountains near Susegierlíck, described, 58.
Pompey’s column, see Symplegades.
Ponte d’Erchiene, see Uzunkupree.
Ponte Grande and Piccolo, two bridges near Constantinople, 38.
Popest, or Priest town, a town in Valachia, 77.
Porphyry pillars, at Mandahóra, 58.
Porta Janicvla, see Seven Towers.
Porumback, a village in Transylvania, described, 89.
Pozzo P. a Jesuit at Vienna, famous for painting, 117.
Prague, the metropolis of Bohemia, described, 134.
The town house, a church and college of Jesuits, Emperor’s palace,
Capuchin cloister, cloister of Premonstratensians (called the
Shawhoff) and university, described, 134, 135, 136, 137.
Premonstratensians, see Prague.
Priest town, see Popest.
Procession at Vienna described, 124.
Prochorvs, a manuscript of the Evangelists said to be written by him, 22.
Proconesvs, see Marmora.
προναος, the outward chapel of a Greek church, 81.
Proserpina, see Messina.
Proszlo, a village in Hungary, 107.
Pruck, a town in Austria, described, 114.
Prvsa ad Arganthonium, see Civs.
Prusia, a city at the foot of mount Olympus, antiently called Prusa ad
Olympum, to distinguish it from Prusa ad Arganthonium, 50.
The manner of spinning silk there, ib.
Its baths, ib.
A Greek inscription there, 51.
Psalms, a copy of them in the characters called Ciceroniani and Cyprianici,
148.
Purse, a summ of money in Turkey equal to an hundred pounds sterling,
82.

Q.
Qvadi, see Moravia.
Quarts, coins current in Valachia, 85, 103.

R.
Rab, a town and river in Hungary, 113.
Rabnitz, a river in Hungary, ib.
Rabutin General, his character, 92.
Rasgrad, a palace belonging to the pashá of Nicopoli, 76.
Reis effendi, the high chancellor in Turkey, 65.
Reisner George, senator of Helmanstadt, 90, 91.
Rhegivm, a town on the coast of Naples, 175.
Rhenish wine, see Hamburg.
Rhoetevm, near Troy, described, 34.
Rhyndacvs, a river in Phrygia, 51.
Robbers, how treated in Turkey, 70.
Rodolphvs Avgvstvs, Duke of Brunswick, his house at Hessen, 146.
His government and character, 148, 149.
Rodope, a mountain in Thrace, 62.
Romanvs, consul of Leipsick, 141.
Rosnaw, a town in Transylvania, 87.
Rotterdam, a city in Holland, 163.
Rukar, a village in Valachia, described, 84.
Rumeli Hisar, or the Roman Castle, the antient Sestos in Thrace, 36.
So called from Rum-yli, the part of the Romans (the later Greeks
taking on them the name of Ῥωμαῖοι) and hisar a castle. See
Cantem. p. 75.
Ryswick, a village in Holland, 162.

S.
Sacred curtain, see αγια πυλη.

Sala, a river in Suabia, 145.


Salt Pits, at Saltzburg, 92.
Therda, 96.
And Hall, 145.
Saltzburg, a town in Transylvania, so called from the salt pits there, 92.
Samos, a river in Transylvania, 96.
Samothracia, an island opposite to the mouth of the Hebrus in Thrace, 34.
Sardam, a town in Holland, some account of it, 166.
Sardis, a city in Lydia, now called Sart, 15.
Its ruins described, 16.
Sart, see Sardis.
Saxons, settled in Transylvania under Geysa the second king of Hungary,
99.
Their government, 100.
And religion, 101.
Saxony, the manner of the Duke’s investiture by the Emperor, 124.
Sazawa, a river in Bohemia, 133.
Scacchia ludus, a book written upon that subject by Christianus Augustus,
Duke of Brunswick, 148.
Scala sancta, twenty eight stairs, up which our Savior was led to Pilate’s
house, which were sent to Constantine the Great from Jerusalem by
his mother Helen, and are now kept at the church of St. John
Lateran in Rome, 117.
See Lassel’s Travels, Par. i. p. 113.
Scale, or port, for passing the Hellespont at Jerdáck, 60.
Scamander, a river near Troy, runing into the Hellespont, 34.
Described, 35.
Schaurtzenburg Count, his stratagem in taking the town Rab, 113.
Schonbran, near Vienna, the Emperor’s palace there, and menagerie, 118.
Schutz, an island in the Danube, 112.
Schweka, a village and river in Austria, 114.
Scipio Asiaticvs, see Antiochvs.
Sclavonic language, 85.
Scutari, antiently Chrysopolis, a city in Bithynia opposite to
Constantinople, described, 43.
Scylla and Charybdis described, 173, 174.
Sea compass, its effects on the castle hill at Magnesia, 10.
Seau Count, 89.
His castle at Wissenburg described, 94.
Sedicui, a village near Smyrna, 31.
Selickar aga, the chief sword bearer to the Grand Signior, 69.
Selim Sultan, his mosque at Adrianople described 64.
Selimee turbant described, 66.
Selymbria, a city of Thrace, not far from Heracléa, 38.
Senigee, a village in Thrace, 73.
Seraglio, a Turkish palace, an old one of the Grand Signior at Magnesia, 7.
That at Constantinople described, 45.
And at Adrianople, 63, 66, 67.
Sestos, see Rumeli Hisar.
Seven Towers, a castle at Constantinople, 38.
Described, 48.
Sharkan, a town in Transylvania, described, 88.
Sharshees, porticos at Adrianople for the reception of particular trades, 65.
Sheep of Hungary, their horns long, straight, and twisted; and their wool
exceeding course, 107.
Shepherd Scythians, see Turcmen.
Sheriff, see Three Sheriffs.
Sherradin Count, his dexterity in shooting, 125.
Sicambria, see Buda.
Sigevm, a promontory near Troy, 34.
Sigrivm, see Siguri.
Siguri, a cape in the island Lesbos, 33.
Silk, see Prusia.
Simow, see Aesepvs.
Sinan pashá, his sepulcher at Gallipoli, 61.
Sinvs Cianvs, 49.
Sinvs Melas, see Cardia.
Sipylvs, a mountain near Magnesia, 5.
Described, 12.
Sloney, a town in Bohemia, 138.
Solacks, the Grand Signior’s body guard, 69.
Solomon’s temple, see Hamburg.
Solyman effendi, his account of Roman arms reserved in Magnesia castle,
9.
His civility to the travelers, 10.
Solyman Sultan, his mosque at Constantinople, called the Solymanjá,
described, 40.
Solymanjá, see Solyman Sultan.
Somlyo, formerly a seat of the kings of Hungary, 98.
Sopha, a Turkish room, having the floor covered with a carpet, and a
mattress on both sides, and at the upper end, about a yard broad
and a foot high, over which cloth is laid, or other rich stuff, and
cusheons next the wall to lean upon, 3, 39.
Sophia, princess dowager of Hanover, 150.
Her character, 151.
Sophia Saint, her church at Constantinople, now turned into a Turkish
mosque, described, 47.
Sorndorf, a village in Lunenburg, 152.
Sorricui, a village on the river Bocléw in Mysia Minor, 59.
Sotalea, antiently Cuma, a bay in Aetolia, 32.
Stagnvm Pegasevm communicates with the river Cayster, 21.
Stambol, or Istambal, the Turkish name for Constantinople, 47.
Stanizlo Stephanus, professor of philosophy at Clausenburg in
Transylvania, 97.
Staon, a Bulgarian Christian, aged 120 years, who had three times
changed his teeth, 73.
Statues, one of our Savior in the cloister of the Premonstratensians at
Prague, affirmed to have sweated blood, 136.
A brass one of an old German idol described, 143.
One of Neptune at Messina described, 174.
Another of our Savior and the Virgin, believed to have been taken
from the life, ib.
Steken, a village in Bohemia, 132.
Stephen Saint, his church at Vienna described, 116.
A stone preferred there, as one of those, with which he was
martyred, 117.
Sternfort, a small castle near Hamburg, 153.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookfinal.com

You might also like