Workspace

Elixir

fault tolerant services real time systems and functional APIs

Definition first

What Elixir means

Elixir is a programming language for writing exact instructions, often used for fault tolerant services real time systems and functional APIs. Start with one mental model: input goes through steps and becomes output.

Minimum run factsFile app.exsRun elixir app.exsHabit Transform data through pipes and keep pattern matches explicit
Program

An ordered set of instructions. It reads input, follows rules, and produces output.

Value and variable

A value is data. A variable is the name you use to hold and reuse that data.

Function

A named piece of work. It takes input, does one job, and can return a result.

Runtime

Elixir is the place that actually runs code from app.exs.

First readable code

Program output

entry point output syntax IO.puts
IO.puts(42)
Output 42

Language lineage

Elixir family tree

See where Elixir comes from, which languages feel close, and what to learn next.

roots
ErlangRubyProlog
currentElixirBEAM functional family
familyBEAM functional family
best used for

fault tolerant web systems, realtime services, and concurrent processes

Zero base path

1Read one rule2Predict output3Type from memory4Run checklist5Repeat with one change

Question bank

Search before practice

Pick a stage or search across the open programming bank. Jump straight to the matching drill.

18 matching questions
Q 1ChoiceStage 1 definitions

Elixir practice 1

Elixir question 1. Choose the statement that matches printing a value.

Q 2ChoiceStage 1 definitions

Elixir practice 2

Elixir question 2. Choose the statement that matches naming a value.

Q 3ChoiceStage 1 definitions

Elixir practice 3

Elixir question 3. Choose the statement that matches reusable function.

Q 4ChoiceStage 1 definitions

Elixir practice 4

Elixir question 4. Choose the statement that matches basic collection.

Q 5ChoiceStage 1 definitions

Elixir practice 5

Elixir question 5. Choose the statement that matches printing a value.

Q 6ChoiceStage 1 definitions

Elixir practice 6

Elixir question 6. Choose the statement that matches naming a value.

Q 7ChoiceStage 1 definitions

Elixir practice 7

Elixir question 7. Choose the statement that matches reusable function.

Q 8ChoiceStage 1 definitions

Elixir practice 8

Elixir question 8. Choose the statement that matches basic collection.

Q 9ChoiceStage 1 definitions

Elixir practice 9

Elixir question 9. Choose the statement that matches printing a value.

Q 10ChoiceStage 1 definitions

Elixir practice 10

Elixir question 10. Choose the statement that matches naming a value.

Q 11ChoiceStage 1 definitions

Elixir practice 11

Elixir question 11. Choose the statement that matches reusable function.

Q 12ChoiceStage 1 definitions

Elixir practice 12

Elixir question 12. Choose the statement that matches basic collection.

Q 13ChoiceStage 1 definitions

Elixir practice 13

Elixir question 13. Choose the statement that matches printing a value.

Q 14ChoiceStage 1 definitions

Elixir practice 14

Elixir question 14. Choose the statement that matches naming a value.

Q 15ChoiceStage 1 definitions

Elixir practice 15

Elixir question 15. Choose the statement that matches reusable function.

Q 16ChoiceStage 1 definitions

Elixir practice 16

Elixir question 16. Choose the statement that matches basic collection.

Q 17ChoiceStage 1 definitions

Elixir practice 17

Elixir question 17. Choose the statement that matches printing a value.

Q 18ChoiceStage 1 definitions

Elixir practice 18

Elixir question 18. Choose the statement that matches naming a value.

Multiple choice

Elixir practice 1

Q 1Choicenew

Elixir question 1. Choose the statement that matches printing a value.

IO.puts(42)

Reference

Patterns for app.exs

Elixirelixir app.exs
Recall from memoryRead a small point then write it back without looking
Trace the codeWrite variable values line by line before you run the answer
Type it yourselfCopy less type more and fix one small error at a time

entry point output syntax IO.puts

Program output

IO.puts(42)
  • Run the smallest file first
  • Print one known value
  • Check the output before adding more code

variables assignment types =

Values and names

total = 42
IO.puts(total)
  • Give values readable names
  • Keep one idea per line while learning
  • Trace the value before changing it

function collection List

Functions and collections

defmodule MathBox do
  def add(a, b), do: a + b
end

scores = [40, 2]
IO.puts(length(scores))
  • Keep functions small
  • Return useful values
  • Use the common collection before reaching for frameworks