O'Reilly logo

Elixir Cookbook by Paulo A Pereira

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Data Types and Structures

This chapter will cover the following recipes:

  • Understanding immutability
  • Adding and subtracting lists
  • Combining tuples into a list
  • Creating and manipulating keyword lists
  • Using pattern matching
  • Pattern matching an HTTPoison response
  • Creating a key/value store with a map
  • Mapping and reducing enumerables
  • Generating lazy (even infinite) sequences
  • Streaming a file as a resource

Understanding immutability

In Elixir, data, once created, is immutable. Whenever some input is passed into a function to be transformed, the original value remains unchanged and a new value is created.

This allows for safe concurrent access to the same data by n processes. It makes concurrency easier to manage, as it is guaranteed that no process can ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required