What is a charlist in Elixir

Published on

A charlist in Elixir is

a list of Unicode code points

For example, if you use your IEx shell (using the iex command) and type:

iex(24)> i [104, 101, 108, 108, 111]

you’ll get the following output:

iex(24)> i [104, 101, 108, 108, 111]
Data type
  This is a list of integers that is printed as a sequence of characters
  delimited by single quotes because all the integers in it represent printable
  ASCII characters. Conventionally, a list of Unicode code points is known as a
  charlist and a list of ASCII characters is a subset of it.
Raw representation
  [104, 101, 108, 108, 111]
Reference modules
Implemented protocols
  Collectable, Enumerable, IEx.Info, Inspect, List.Chars, String.Chars

The list [104, 101, 108, 108, 111] is a list of printable ASCII numbers, thus when evaluated is treated as a charlist

Here, have a slice of pizza 🍕