O'Reilly logo

Learning Elixir by Kenny Ballou

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Stream processing and Elixir

Since Elixir is functional, stream processing in Elixir is quite simple. We have functions such as Enum.map/2, Enum.filter/2, and Enum.reduce/2. Further still, we have a way to express computations inherently as flows, even if we are not (yet) completely taking advantage of flow-based programming.

Simply, the |> operator is a way to express program flow as you read it. Rather than awkwardly writing programs inside out or right to left, we can express our computation naturally from left to right. Let's begin to examine some simple examples of this.

Quickly, let's take a look at our map/2 function from earlier chapters:

iex(1)> defmodule MyMap do
...(1)> def map([], _), do: []
...(1)> def map([h|t], f), do: [f.(h) | map(t, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required