HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to ElixirVariablesData TypesOperatorsStringsListsConditions (if / else)Iteration (Enum)Functions
REFERENCE
📖 Overview
🖥️ Output
📦 Variables & Types
🔢 Numbers & Math
✍️ String
📚 List & Enum
List ( [ ] )Enum (each / map / sum)
🔀 Condition
🧩 Function
Elixir›REFERENCE›List & Enum
📚

List & Enum

Lists and the Enum module.

CommandDescription
List ( [ ] )An ordered, immutable collection of values.
Enum (each / map / sum)Iteration/transformation over collections.

List ( [ ] )

Try it yourself →

An ordered, immutable collection of values.

Syntax

l = [1, 2];  Enum.at(l, 0);  length(l);  l ++ [x]

Description

Lists are created with square brackets. Enum.at(l, 0) gives the first element (0-indexed), length gives the count. ++ returns a new list (immutable).

Example

l = [1, 2]
yeni = l ++ [3]
IO.inspect(yeni)
IO.puts(Enum.at(yeni, 0))
IO.puts(length(yeni))

Expected output

[1, 2, 3]
1
3

When to use?

Data collections; processing with Enum.

Enum (each / map / sum)

Try it yourself →

Iteration/transformation over collections.

Syntax

Enum.each(collection, fn)   Enum.map(...)   Enum.sum(...)

Description

In Elixir, Enum is used instead of loops. each performs an action on each element, map transforms, sum adds up. 1..n is a range.

Example

Enum.each(1..3, fn i -> IO.puts(i) end)
IO.inspect(Enum.map([1, 2, 3], fn x -> x * x end))
IO.puts(Enum.sum(1..100))

Expected output

1
2
3
[1, 4, 9]
5050

When to use?

List processing, transformation, reduction (map/filter/reduce).

HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code