0PricingLogin
Elixir & Phoenix: Scalable Backend Development · Lesson

Functions, Modules, and Pipelining

Learn to define functions, organize code into modules, and use the pipe operator for clear data transformations.

Introduction to Elixir Functions

In Elixir, functions are the building blocks of your programs. They take inputs, perform operations, and return outputs.

Elixir functions are designed to be pure: they don't change data outside their scope and always produce the same output for the same input. This makes your code predictable and easier to reason about.

Defining Public Functions

You define public functions using the def keyword. These functions can be called from anywhere within your application, provided they are part of a module.

Let's create a simple function that adds two numbers:

defmodule MathOperations do
  def add(a, b) do
    a + b
  end
end

IO.puts "Sum of 5 and 3: #{MathOperations.add(5, 3)}"

All lessons in this course

  1. Functions, Modules, and Pipelining
  2. Working with Enumerable Collections
  3. Recursion and Higher-Order Functions
  4. Lazy Evaluation with the Stream Module
← Back to Elixir & Phoenix: Scalable Backend Development