Home Page Icon
Home Page
Table of Contents for
Introducing Elixir
Close
Introducing Elixir
by J. David Eisenberg, Simon St. Laurent
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
11. Static Analysis, Typespecs, and Testing
Static Analysis
Typespecs
Writing Unit Tests
Setting up Tests
Embedding Tests in Documentation
12. 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
13. Getting Started with OTP
Creating Services with gen_server
A Simple Supervisor
Packaging an Application with Mix
14. 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
15. Using Phoenix
Skeleton installation
Structuring a Basic Phoenix Application
Presenting a Page
Routing
A Simple Controller
A Simple View
Calculating
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
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Cover
Next
Next Chapter
Introducing Elixir
Introducing Elixir
Simon St. Laurent and J. David Eisenberg
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset