Elixir Functions

Functions in Elixir are recursive by default and often written as small pure transformations with explicit data flow.

Definitions

def greet(name), do: "Hello, #{name}!"

Anonymous functions

Anonymous functions are useful for callbacks, short transformations, and passing behavior around.

Pipe operator

The pipe operator keeps transformation chains readable by threading a value through a sequence of calls.

Practice

  1. Write one recursive function.
  2. Use one anonymous function with Enum.
  3. Rewrite one nested expression with the pipe operator.