Learn Functional Programming with Elixir: New Foundations for a New World

Learn Functional Programming with Elixir: New Foundations for a New World

by Ulisses Almeida

Paperback

$38.77 $42.95 Save 10% Current price is $38.77, Original price is $42.95. You Save 10%.
Choose Expedited Shipping at checkout for guaranteed delivery by Wednesday, January 29
MARKETPLACE
12 New & Used Starting at $23.71

Overview

Elixir's straightforward syntax and this guided tour give you a clean, simple path to learn modern functional programming techniques. No previous functional programming experience required! This book walks you through the right concepts at the right pace, as you explore immutable values and explicit data transformation, functions, modules, recursive functions, pattern matching, high-order functions, polymorphism, and failure handling, all while avoiding side effects. Don't board the Elixir train with an imperative mindset! To get the most out of functional languages, you need to think functionally. This book will get you there.

Functional programming offers useful techniques for building maintainable and scalable software that solves today's difficult problems. The demand for software written in this way is increasing - you don't want to miss out. In this book, you'll not only learn Elixir and its features, you'll also learn the mindset required to program functionally. Elixir's clean syntax is excellent for exploring the critical skills of using functions and concurrency.

Start with the basic techniques of the functional way: working with immutable data, transforming data in discrete steps, and avoiding side effects. Next, take a deep look at values, expressions, functions, and modules. Then extend your programming with pattern matching and flow control with case, if, cond, and functions. Use recursive functions to create iterations. Work with data types such as lists, tuples, and maps. Improve code reusability and readability with Elixir's most common high-order functions. Explore how to use lazy computation with streams, design your data, and take advantage of polymorphism with protocols. Combine functions and handle failures in a maintainable way using Elixir features and libraries.

Learn techniques that matter to make code that lives harmoniously with the language.

What You Need:

You'll need a computer and Elixir 1.4 or newer version installed. No previous functional programming or Elixir experience is required. Some experience with any programming language is recommended.

Product Details

ISBN-13: 9781680502459
Publisher: Pragmatic Programmers, LLC, The
Publication date: 03/05/2018
Pages: 200
Product dimensions: 9.00(w) x 7.50(h) x 0.60(d)

About the Author

Ulisses Almeida is a software consultant at Plataformatec, the company that created Elixir. He works on crafting applications, coaching beginner developers, and advising customers on best practices to build robust and maintainable systems.

Table of Contents

Acknowledgments vii

Introduction ix

1 Thinking Functionally 1

Why Functional? 1

Working with Immutable Data 3

Building Programs with Functions 4

Declaring Code 7

Wrapping Up 9

2 Working with Variables and Functions 11

Representing Values 11

Executing Code and Generating a Result 12

Binding Values in Variables 15

Creating Anonymous Functions 17

Naming Functions 24

Wrapping Up 30

3 Using Pattern Matching to Control the Program Flow 33

Making Two Things Match 33

Unpacking Values from Various Data Types 35

Control Flow with Functions 45

Expanding Control with Guard Clauses 48

Elixir Control-Flow Structures 53

Wrapping Up 56

4 Diving into Recursion 59

Surrounded by Boundaries 59

Conquering Recursion 65

Tail-Call Optimization 70

Functions Without Borders 73

Using Recursion with Anonymous Functions 78

Wrapping Up 79

5 Using Higher-Order Functions 81

Creating Higher-Order Functions for Lists 81

Using the Enum Module 87

Using Comprehensions 89

Pipelining Your Functions 89

Be Lazy 93

Wrapping Up 102

6 Designing Your Elixir Applications 105

Starting Your Project with Mix 105

Designing Entities with Structs 110

Using Protocols to Create Polymorphic Functions 117

Creating Module Behaviours 124

Wrapping Up 136

7 Handling Impure Functions 139

Pure vs. Impure Functions 140

Controlling the Flow of Impure Functions 143

Trying, Rescuing, and Catching 146

Handling Impure Functions with the Error Monad 150

Using with 155

Wrapping Up 158

A1 Adding Rooms to the Game 161

A2 Answers to Exercises 165

Answers for Chapter 2, Working with Variables and Functions 165

Answers for Chapter 3, Using Pattern Matching to Control the Program Flow 166

Answers for Chapter 4, Diving into Recursion 168

Answers for Chapter 5. Using Higher-Order Functions 171

Bibliography 175

Index 177

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews