RESOURCES / ELIXIR CHEAT SHEET
Elixir cheat sheet

Tuples

Untyped structures to group fixed number of elements

person = {"Alice", 35}
age = elem(person, 1)
older_alice = put_elem(person, 1, 26)

Lists

Data structures that can vary in size

some_elements = [1, 3, 8, "two", :five]
length(some_elements)
Enum.at(some_elements, 2)
List.replate_at(...)
List.insert_at(...)
some_list = [h | t]

Maps

Key/value store

some_map = %{}
another_map = %{:name => "Alice"}
another_map_2 = %{name: "Alice"}
Map.get(...)
Map.fetch(...)
Map.fetch!(...)
Map.put(...)

Binaries and bitstrings

Chunk of bytes

<<1, 2, 3>>