更新时间:2021-07-02 23:15:16
封面
版权信息
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Why subscribe?
Customer Feedback
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
Pure Functional Programming in Go
Motivation for using FP
Getting the source code
The directory structure of the source files
How to run our first Go application
Imperative versus declarative programming
Pure functions
Fibonacci sequence - a simple recursion and two performance improvements
Memoization
The difference between an anonymous function and a closure
FP using Go's concurrency constructs
Testing FP using test-driven development
A note about paths
How to run our tests
A journey from imperative programming to pure FP and enlightenment
Benchmark test for the imperative SumLoop function
Benchmark test for the SumRecursive function
A time of reckoning
A quick example of a function literal
Summary
Manipulating Collections
Iterating through a collection
Piping Bash commands
Functors
Functions that modify functions
A coding example of functions that modify functions
A visual example of functions that modify functions
Composition in Mindcraft
Tacit programming
Tacit programming with Unix pipes
Programming CMOS with Unix pipes
Tacit programming with FP
Non-TCO recursive example
TCO recursive example
The importance of recursion
Various intermediate and terminal functions
Reduce example
Intermediate functions
Common intermediate functions
Map Example
Terminal functions
Common terminal functions
Join example
GroupBy example
Predicates
Reflection
Combinator pattern
Map and filter
Contains
Iterating over a collection of cars
The empty interface
The Contains() method
If Go had generics
Map function
Testing our empty interface-based Map function
Itertools
Go channels used by the New function
Testing itertool's Map function
Testing iterators for element equality
Functional packages
Another time of reflection
Go is awesome
Go is awesome but
The cure
Gleam - distributed MapReduce for Golang
LuaJIT's FFI library
Unix pipe tools
Processing Gleam collections
Using High-Order Functions
Characteristics of FP
Function composition
Monads allow us to chain continuations
Generics
First-class functions
Closure
Dynamically scoped
Pure function