Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Introducing Elixir
Preface
Who This Book Is For
Who This Book Is Not For
What This Book Will Do For You
How This Book Works
Other Resources
Elixir Will Change You
Conventions Used in This Book
Using Code Examples
Help This Book Grow
Please Use It For Good
Safari® Books Online
How to Contact Us
Acknowledgments
1. Getting Comfortable
Installation
Installing Erlang
Installing Elixir
Firing It Up
First Steps
Moving Through Text and History
Moving Through Files
Doing Something
Calling Functions
Numbers in Elixir
Working with Variables in the Shell
2. Functions and Modules
Fun with fn
And the &
Defining Modules
From Module to Free-Floating Function
Splitting Code Across Modules
Combining Functions with the Pipe Operator
Importing Functions
Default Values for Arguments
Documenting Code
Documenting Functions
Documenting Modules
3. Atoms, Tuples, and Pattern Matching
Atoms
Pattern Matching with Atoms
Atomic Booleans
Guards
Underscoring That You Don’t Care
Adding Structure: Tuples
Pattern Matching with Tuples
Processing Tuples
4. Logic and Recursion
Logic Inside of Functions
Evaluating Cases
Adjusting to Conditions
If, or else
Variable Assignment in case and if Constructs
The Gentlest Side Effect: IO.puts
Simple Recursion
Counting Down
Counting Up
Recursing with Return Values
5. Communicating with Humans
Strings
Multiline Strings
Unicode
Character Lists
String Sigils
Asking Users for Information
Gathering Characters
Reading Lines of Text
6. Lists
List Basics
Splitting Lists into Heads and Tails
Processing List Content
Creating Lists with Heads and Tails
Mixing Lists and Tuples
Building a List of Lists
7. Name-Value Pairs
Keyword Lists
Lists of Tuples with Multiple Keys
Hash Dictionaries
From Lists to Maps
Creating Maps
Updating Maps
Reading Maps
From Maps to Structs
Setting Up Structs
Creating and Reading Structs
Pattern Matching Against Structs
Using Structs in Functions
Adding Behavior to Structs
Adding to Existing Protocols
8. Higher-Order Functions and List Comprehensions
Simple Higher-Order Functions
Creating New Lists with Higher-Order Functions
Reporting on a List
Running List Values Through a Function
Filtering List Values
Beyond List Comprehensions
Testing Lists
Splitting Lists
Folding Lists
9. Playing with Processes
The Shell Is a Process
Spawning Processes from Modules
Lightweight Processes
Registering a Process
When Processes Break
Processes Talking Amongst Themselves
Watching Your Processes
Watching Messages Among Processes
Breaking Things and Linking Processes
10. Exceptions, Errors, and Debugging
Flavors of Errors
Rescuing Code from Runtime Errors as They Happen
Logging Progress and Failure
Tracing Messages
Watching Function Calls
Writing Unit Tests
11. Storing Structured Data
Records: Structured Data Before structs
Setting Up Records
Creating and Reading Records
Using Records in Functions
Storing Data in Erlang Term Storage
Creating and Populating a Table
Simple Queries
Overwriting Values
ETS Tables and Processes
Next Steps
Storing Records in Mnesia
Starting up Mnesia
Creating Tables
Reading Data
12. Getting Started with OTP
Creating Services with gen_server
A Simple Supervisor
Packaging an Application with Mix
13. Using Macros to Extend Elixir
Functions versus Macros
A Simple Macro
Creating New Logic
Creating Functions Programatically
When (Not) to Use Macros
Sharing the Gospel of Elixir
A. An Elixir Parts Catalog
Shell Commands
Reserved Words
Operators
Guard Components
Common Functions
Datatypes for Documentation and Analysis
B. Generating Documentation with ExDoc
Using ExDoc with mix
Index
Colophon
Copyright
← Prev
Back
Next →
← Prev
Back
Next →