What Is Elixir Lambda And When To Use Them — Tentamen Software Testing Blog

Image for post
Image for post
Elixir Lambda Function



Lambda is the eleventh letter of the Greek alphabet (Λ, λ), transliterated as ‘l.’

In Elixir, Lambda is First Class Function, a function that is not bound to a global name. Instead, we assign a lambda to a variable, so we could call it using that variable.

In the picture above, we define Croatian pdv lambda. Note how we call a lambda using . notation. This is needed to distinguish from getting named functions.

Image for post
Image for post

Lambda function could be passed as an argument to another function. An example is Enum.map` where lambda is called for each enumbrable element. In our case [1, 2, 3].

There is a shorter way to define a lambda using & the operator. The number represents the lambda attribute position.

I do not recommend using this shorten notation, because it makes your code hard to read, even for your future self.


  • the dot notation
  • lambda as argument of another function
  • shorten notation using &

Originally published at https://blog.tentamen.eu on September 11, 2020.

Written by

Founder of Tentamen, software testing agency.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store