更新时间:2021-07-30 09:44:45
封面
版权页
Credits
About the Author
Aknowledgement
About the Reviewers
www.PacktPub.com
Support files eBooks discount offers and more
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Chapter 1. Grokking the Functional Way
Abstractions
Concise expression
Functions
Immutable
Referential transparency
The problem – grouping continuous integers
Scala idioms
Patterns and those aha! moments
Summary
Chapter 2. Singletons Factories and Builders
Singletons – being one and only one
Null Objects – singletons in another garb
Scala singletons
Builders
Chapter 3. Recursion and Chasing your Own Tail
Recursive structures
Pattern matching
Tail recursion to the rescue
Getting the nth element of a list
An expression parser
Persistent data structures
Two forms of recursion
Chapter 4. Lazy Sequences – Being Lazy Being Good
Illusion and reality – the proxy pattern
Hibernate's lazy loading
Lazy val – calling by need
Infinite sequences – Scala streams
Recursive streams
Memoization and the flyweight pattern
Call by name
Streams are collections
Sieve of Eratosthenes
A view to a collection
Chapter 5. Taming Multiple Inheritance with Traits
The iterator design pattern
Interfaces as types
The dreaded diamond
Traits – Scala's rich interfaces
Mix-ins – rich interfaces
Frills and thrills – the decorator pattern
Scala's easy and breezy decorations – stackable modifications
Dependencies injection pattern
A taste of the cake pattern
Sealed traits
Defeating the dreaded diamond
Chapter 6. Currying Favors with Your Code
Functions as first-class values
Roping in a scope
Local functions – hiding and biding their time
The underscore – Scala's Swiss army knife
A taste of the curry
The loan pattern
Serving the curry
Frills and thrills – decorators again
Wrapping it up
Chapter 7. Of Visitors and Chains of Responsibilities
A tale of two hierarchies
The Visitor pattern
Partial functions
The chain of responsibility
Chapter 8. Traversals – Mapping/Filtering/Folding/Reducing
Iterating the Scala way
A validation problem
Foreach–sugary sweetener
Monads
Reduce
Chapter 9. Higher Order Functions
The strategy design pattern
A strategy in Scala land
Functors
FlatMap
Monoids
An inverted index
Pipes and filters
Pipes and filters – the Scala version
It is a Monoid