Études for Elixir

Book description

This book includes descriptions of programs that you can write in Elixir. The programs will usually be short, and each one has been designed to provide practice material for a particular Elixir programming concept. These programs have not been designed to be of considerable difficulty, though they may ask you to stretch a bit beyond the immediate material and examples that you find in the book Introducing Elixir.

Table of contents

  1. Études for Elixir
    1. Contributor Guidelines
    2. How to Contribute
      1. Create a GitHub account
      2. Copy (“fork”) the project repository to your account
      3. Edit your file using AsciiDoc
      4. Double check your submission and add your biography
      5. Submit a pull request
      6. Engage in back-and-forth
  2. Preface: What’s an étude?
    1. What are Études for Elixir?
    2. How This Book was Written
    3. Elixir is a Young Language
    4. Acknowledgments
  3. 1. Getting Comfortable with Elixir
    1. Étude 1-1: Experimenting with Errors
  4. 2. Functions and Modules
    1. Étude 2-1: Writing a Function
    2. Étude 2-2: Writing a Function with Default Values
    3. Étude 2-3: Documenting a Module
    4. Étude 2-4: Discovery Étude
  5. 3. Atoms, Tuples, and Pattern Matching
    1. Étude 3-1: Pattern Matching
    2. Étude 3-2: Guards
    3. Étude 3-3: Underscores
    4. Étude 3-4: Tuples as Parameters
  6. 4. Logic and Recursion
    1. Étude 4-1: Using case
    2. Étude 4-2: Recursion
    3. Étude 4-3: Non-Tail Recursive Functions
    4. Étude 4-4: Tail Recursion with an Accumulator
    5. Étude 4-5: Recursion with a Helper Function
  7. 5. Strings
    1. Étude 5-1: Validating Input
    2. Étude 5-2: Better Validation with Regular Expressions
    3. Étude 5-3: Using String.split
  8. 6. Lists
    1. Étude 6-1: Recursive Iteration through a List
    2. Étude 6-2: Accumulating the Sum of a List
    3. Interlude: “Mistakes were made.”
    4. Étude 6-3: Lists of Lists
    5. Étude 6-4: Random Numbers; Generating Lists of Lists
  9. 7. Hashes
    1. Étude 7-1: Creating a HashDict from a File
      1. Opening Files
    2. Étude 7-2: Creating Structures from a File
    3. Étude 7-3: Using Structures
    4. Étude 7-4: Protocols with Structures
  10. 8. Higher Order Functions and List Comprehensions
    1. Étude 8-1: Simple Higher Order Functions
    2. Étude 8-2: List Comprehensions and Pattern Matching
    3. Étude 8-3: Using lists:foldl/3
    4. Étude 8-4: Using Enum.split/2
    5. Étude 8-5: Multiple Generators in List Comprehensions
    6. Étude 8-6: Explaining an Algorithm
  11. 9. Processes
    1. Étude 9-1: Using Processes to Simulate a Card Game
      1. The Art of War
      2. War: What is it good for?
      3. Pay Now or Pay Later
      4. The Design
      5. Messages Are Asynchronous
      6. Hints for Testing
  12. 10. Handling Errors
    1. Étude 10-1: try and rescue
    2. Étude 10-2: Logging Errors
  13. 11. Storing Structured Data
    1. Étude 11-1: Using ETS
      1. Part One
      2. Part Two
  14. 12. Getting Started with OTP
    1. Étude 12-1: Get the Weather
      1. Obtaining Weather Data
      2. Parsing the Data
      3. Set up a Supervisor
    2. Étude 12-2: Wrapper Functions
    3. Étude 12-3: Independent Server and Client
    4. Étude 12-4: Chat Room
      1. The Chatroom Module
      2. The Person Module
      3. Wrapper Functions for the Person module
      4. Putting it All Together
  15. 13. Using Macros to Extend Elixir
    1. Étude 13-1: Atomic weights
    2. Étude 13-2: Adding Durations
    3. Étude 13-3: Adding Durations (operator version)
  16. 14. Contributors
  17. A. Solutions to Études
    1. Solution 2-1
      1. geom.ex
    2. Solution 2-2
      1. geom.ex
    3. Solution 2-3
      1. geom.ex
    4. Solution 3-1
      1. geom.ex
    5. Solution 3-2
      1. geom.ex
    6. Solution 3-3
      1. geom.ex
    7. Solution 3-4
      1. geom.ex
    8. Solution 4-1
      1. geom.ex
    9. Solution 4-2
      1. dijkstra.ex
    10. Solution 4-2
      1. dijkstra.ex
    11. Solution 4-3
      1. powers.ex
      2. powers_traced.ex
    12. Solution 4-4
      1. powers.ex
    13. Solution 4-5
      1. powers.ex
    14. Solution 5-1
      1. geom.ex
      2. ask_area.ex
    15. Solution 5-2
      1. ask_area.ex
    16. Solution 5-3
      1. dates.ex
    17. Solution 6-1
      1. stats.ex
    18. Solution 6-2
      1. dates.ex
      2. dates.ex
    19. Solution 6-3
      1. teeth.ex
      2. stats.ex
    20. Solution 6-4
      1. non_fp.ex
    21. Solution 7-1
      1. college.ex
    22. Solution 7-1
      1. geography.ex
    23. Solution 7-3
      1. geography.ex
    24. Solution 7-4
      1. city.ex
    25. Solution 8-1
      1. calculus.ex
    26. Solution 8-2
      1. list_comp.ex
    27. Solution 8-3
      1. stats.ex
    28. Solution 8-4
      1. dates.ex
    29. Solution 8-5
      1. cards.ex
    30. Solution 8-6
      1. cards.ex
    31. Solution 9-1
      1. cards.ex
      2. game.ex
      3. player.ex
    32. Solution 10-1
      1. stats.ex
    33. Solution 10-2
      1. bank.ex
    34. Solution 11-1
      1. phone_ets.ex
      2. generate_calls.ex
    35. Solution 12-1
      1. weather.ex
      2. weather_sup.ex
    36. Solution 12-2
      1. weather.ex
    37. Solution 12-3
    38. Solution 12-4
      1. chatroom.ex
      2. person.ex
    39. Solution 13-1
      1. atomic_maker.ex
      2. atomic.ex
    40. Solution 13-2
      1. duration.ex
    41. Solution 13-3
      1. duration.ex
  18. B. A Brief Introduction to Regular Expressions
    1. The Simplest Patterns
    2. Matching Sets of Characters
    3. Anchors
    4. Repetition
  19. Copyright

Product information

  • Title: Études for Elixir
  • Author(s): J. David Eisenberg
  • Release date: October 2014
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781449372217