SlideShare a Scribd company logo
Getting Functional
with Elixir
Because functions love to be First class citizens.
Whoami
Athira Mukundan
Solution Consultant @Sahaj
athira_tech@yahoo.in
Elixir Makes Functional
Programming Accessible
It’s for everyone!
Some history.
Influenced by Ruby Runs on Erlang VM
WHAT IS FUNCTIONAL PROGRAMMING?
Declarative
Paradigm
What vs How
Imperative paradigm Declarative paradigm
var activeUsers = new List<User>();
for(var i = 0; i < users.length;
i++){
if(users[i].isActive){
activeUsers.add(users[i]);
}
}
Enum.filter(users, fn u ->
u.is_active end)
WHAT IS FUNCTIONAL PROGRAMMING?
Declarative
Paradigm
Functions as
First Class
Citizens
Functions have power
is_active = fn u -> u.is_active end
Enum.filter(users, is_active)
WHAT IS FUNCTIONAL PROGRAMMING?
Declarative
Paradigm
Functions as
First Class
Citizens
Immutability
Data doesn’t change
users = [%{is_active: true}, %{is_active: false}]
active_users = Enum.filter(users, is_active)
users = [%{is_active: true}, %{is_active: false}]
active_users = [%{is_active: true}]
How I Want to Filter Users
users.filter(is_active)
Enum.filter(users, is_active)
That’s it! Let’s see some
ELIXIR now!
Pipe Operator |>
Enum.filter(Enum.map(String.split(File.read!("tweets.txt"),
~r{n}), &String.strip/1), fn x -> String.length(x) <= 140 end)
Path
|> File.read!
|> String.split(~r{n})
|> Enum.map(&String.trim/1)
|> Enum.filter(fn x -> String.length(x) <= 140 end)
Debugging with |>
my_list = [[1], [2,3], [4,5,6]]
My_list
|> Enum.at(1)
|> IO.inspect #[2,3]
|> Enum.at(0)
Functions have power: Composition
def get_contents(path) do
path
|> File.read!
|> String.split(~r{n})
|> Enum.map(&String.strip/1)
|> Enum.filter(fn x -> String.length(x) <= 140 end)
end
Pattern Matching
{first, last} = {“Athira”, “Mukundan”}
first: “Athira”
last: “Mukundan”
{first, “Mukundan”} = {“Athira”, “Mukundan”}
first: “Athira”
{first, “Abc”} = {“Athira”, “Diaz”}
** (MatchError) no match of right hand side value:
{"Abc", ”Diaz"}
Pattern Matching: Return Values
case File.read(filename) do
{:ok, file} -> IO.puts(file)
{:error, reason} -> IO.puts(reason)
end
Pattern Matching: Structs
def special_event(date) do
case date do
{10, 31, _} -> :halloween
{1, 1, _} -> :new_years
{_, 1, _} -> :first_of_the_month
{_, _, 2000} -> :y2k
_ -> :boring
end
end
Pattern Matching: Function Parameters
def is_dynamic(:c), do: :false
def is_dynamic(:elixir), do: :true
def is_dynamic(_other), do: :unknown
Pattern Matching: Recursion
def reverse(list) do
reverse(list, [])
end
def reverse([], reversed), do: reversed
def reverse([head | tail], reversed), do:
reverse(tail, [head | reversed])
Elixir Processes
● all code runs inside processes
● isolated from each other
● communicate via message passing
● < ~1Kb
● basis for concurrency in Elixir
● provide the means for building distributed and fault-
tolerant programs.
Elixir Processes
Actor concurrency model
● An actor is the primitive unit of computation. It’s the thing that
receives a message and do some kind of computation based on it.
● Actors are completely isolated from each other
● Never share memory.
More Elixir?
● Genserver
● Supervisors
● Nodes
So How Do I Get Started?
https://elixir-lang.org/
http://exercism.io/
Recap
What not How
Functions have
Power
Data doesn’t
change
A Recap

More Related Content

PPTX
Actions & Filters In WordPress
PDF
Jqeury ajax plugins
PPTX
Closure
PPTX
Java Script Promise
PDF
Mysql & Php
PDF
Deep Dive into React Hooks
PPS
Actions & Filters In WordPress
Jqeury ajax plugins
Closure
Java Script Promise
Mysql & Php
Deep Dive into React Hooks

What's hot (20)

PDF
Functional Programming
KEY
jQuery - Tips And Tricks
PPTX
SPFx: Working with SharePoint Content
PPTX
SPFx working with SharePoint data
PDF
Apache Pig Relational Operators - II
PDF
Teach Yourself some Functional Programming with Scala
PDF
Extending Redux in the Server Side
ZIP
レガシーコード改善ガイド
PPTX
Iterators & generators: practical uses in memory management
KEY
jQuery Namespace Pattern
DOCX
Week 12 code
PDF
Selenium cheat sheet
PDF
Flask 소수전공 강의자료 - 3차시
PDF
Who killed object oriented design?
PPTX
PHP function
PPTX
Jquery plugin development
PDF
Flask 소수전공 강의자료 - 4차시
PPT
KMUTNB - Internet Programming 6/7
PPTX
Алексей Плеханов: Новинки Laravel 5
DOCX
getSIDUsers
Functional Programming
jQuery - Tips And Tricks
SPFx: Working with SharePoint Content
SPFx working with SharePoint data
Apache Pig Relational Operators - II
Teach Yourself some Functional Programming with Scala
Extending Redux in the Server Side
レガシーコード改善ガイド
Iterators & generators: practical uses in memory management
jQuery Namespace Pattern
Week 12 code
Selenium cheat sheet
Flask 소수전공 강의자료 - 3차시
Who killed object oriented design?
PHP function
Jquery plugin development
Flask 소수전공 강의자료 - 4차시
KMUTNB - Internet Programming 6/7
Алексей Плеханов: Новинки Laravel 5
getSIDUsers
Ad

Similar to Getting functional with elixir (20)

PPTX
Get functional with elixir short
PPTX
PDF
Elixir and OTP Apps introduction
PDF
Programming Elixir 13 Functional Concurrent Pragmatic Fun Dave Thomas
PDF
Elixir talk
PDF
Programming Elixir Functional Concurrent Pragmatic Fun 1st Edition Dave Thomas
PDF
Introduction to Elixir
PDF
Functional Programming With Elixir
PDF
Elixir in a nutshell - Fundamental Concepts
PPTX
Elixir Study Group Kickoff Meetup
PPTX
Introducing Elixir
PDF
Elixir
PDF
What is the deal with Elixir?
ODP
Elixir basics
PDF
Learning Elixir as a Rubyist
PPTX
Introduction to functional programming, with Elixir
PDF
Elixir and Phoenix for Rubyists
PDF
My elixir helWo lorld
PPTX
A sip of elixir
ODP
Elixir basics-2
Get functional with elixir short
Elixir and OTP Apps introduction
Programming Elixir 13 Functional Concurrent Pragmatic Fun Dave Thomas
Elixir talk
Programming Elixir Functional Concurrent Pragmatic Fun 1st Edition Dave Thomas
Introduction to Elixir
Functional Programming With Elixir
Elixir in a nutshell - Fundamental Concepts
Elixir Study Group Kickoff Meetup
Introducing Elixir
Elixir
What is the deal with Elixir?
Elixir basics
Learning Elixir as a Rubyist
Introduction to functional programming, with Elixir
Elixir and Phoenix for Rubyists
My elixir helWo lorld
A sip of elixir
Elixir basics-2
Ad

Recently uploaded (20)

PDF
Understanding Forklifts - TECH EHS Solution
PDF
Nekopoi APK 2025 free lastest update
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
history of c programming in notes for students .pptx
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Introduction to Artificial Intelligence
PPTX
Transform Your Business with a Software ERP System
PPTX
ai tools demonstartion for schools and inter college
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPT
Introduction Database Management System for Course Database
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
top salesforce developer skills in 2025.pdf
PDF
Digital Strategies for Manufacturing Companies
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Understanding Forklifts - TECH EHS Solution
Nekopoi APK 2025 free lastest update
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
CHAPTER 2 - PM Management and IT Context
history of c programming in notes for students .pptx
2025 Textile ERP Trends: SAP, Odoo & Oracle
Designing Intelligence for the Shop Floor.pdf
Design an Analysis of Algorithms I-SECS-1021-03
Introduction to Artificial Intelligence
Transform Your Business with a Software ERP System
ai tools demonstartion for schools and inter college
Design an Analysis of Algorithms II-SECS-1021-03
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Introduction Database Management System for Course Database
Which alternative to Crystal Reports is best for small or large businesses.pdf
Reimagine Home Health with the Power of Agentic AI​
top salesforce developer skills in 2025.pdf
Digital Strategies for Manufacturing Companies
Embracing Complexity in Serverless! GOTO Serverless Bengaluru

Getting functional with elixir