SlideShare a Scribd company logo
1 of 44
Download to read offline
Erlang Elixir|>
Elixir
José Valim - co-fondateur de Plataformatec
(http://plataformatec.com.br)
Proposer la puissance de la machine virtuelle Erlang
d’une manière différente aux développeurs.
Premier commit date de janvier 2011
Version actuelle : 0.10.2 / 0.10.3-dev
Release finale est prévue pour juin 2014
Erlang :
wget http://www.erlang.org/download/otp_src_R16B02.tar.gz
tar zxf otp_src_R16B02.tar.gz
cd otp_src_R16B02
./configure
make
sudo make install
Elixir :
git clone https://github.com/elixir-lang/elixir.git
cd elixir
make
sudo make install
Les variables
Erlang :
• /^(?:_[a-zA-Z0-9_]|[A-Z])[a-zA-Z0-9_]*$/
• single assignment
Elixir :
• /^(?:_[a-zA-Z0-9_]|[a-z])[a-zA-Z0-9_]*$/
• re assignment
Erlang :
1> A = [1, 2, 3].
[1, 2, 3]
2> A = [4, 5, 6].
** exception error: no match of right hand side value [4,5,6]
Elixir :
iex(1)> a = [1, 2, 3]
[1, 2, 3]
iex(2)> a = [4, 5, 6]
[4, 5, 6]
Les variables
iex(1)> a = [1, 2, 3]
[1, 2, 3]
iex(2)> [b, c, d] = a
[1, 2, 3]
iex(3)> b
1
iex(4)> c
2
iex(4)> d
3
iex(1)> a = [1, 2, 3]
[1, 2, 3]
iex(2)> [b | tail] = a
[1, 2, 3]
iex(3)> b
1
iex(4)> tail
[2, 3]
atomes
:an_atom
:"an atom!"
booléens
true
false
listes [104,101,108,108,111] = ‘hello’
tuples {1, :tuple, ‘de’, "données"}
fonctions
my_fun = fn(x) -> x*x end
my_fun.(3)
regex %r/erlang|elixir/
range [1..10]
hash
[key1: "value1", key2: 3, ...]
[{"Une clé", "sa valeur»}, ...]
Les binaires : séquence d’entiers (0-255 / 8 bits)
placée entre << et >>
Les binaires : séquence d’entiers (0-255 / 8 bits)
placée entre << et >>
<<104, 101, 108, 108, 111>>
Les binaires : séquence d’entiers (0-255 / 8 bits)
placée entre << et >>
<<[104, 101, 108, 108, 111]>>
<<104, 101, 108, 108, 111>>
Les binaires : séquence d’entiers (0-255 / 8 bits)
placée entre << et >>
<<[104, 101, 108, 108, 111]>>
<<'hello'>>
<<104, 101, 108, 108, 111>>
Les binaires : séquence d’entiers (0-255 / 8 bits)
placée entre << et >>
<<[104, 101, 108, 108, 111]>>
<<'hello'>>
"hello"
<<104, 101, 108, 108, 111>>
<<259>> = ?
<<259>> = <<3>>
<<259>> = <<3>>
<<259:size(16)>> = <<1, 3>>
<<259>> = <<3>>
<<259:size(16)>> = <<1, 3>>
<<x:size(16)>> = <<1, 3>>
<<2.4>>
<<2.4>>
** (ArgumentError) argument error
:erl_eval.expr/3
<<2.4>>
<<2.4:float>> =
<<64, 3, 51, 51, 51, 51, 51, 51>>
** (ArgumentError) argument error
:erl_eval.expr/3
<<2.4>>
<<2.4:float>> =
<<64, 3, 51, 51, 51, 51, 51, 51>>
** (ArgumentError) argument error
:erl_eval.expr/3
les flottants sont codés sur 64 bits ; le premier bit pour
coder le signe, les 11 suivants pour l’exposant, puis 52
bits pour la mantisse et le dernier, implicite.
binary, bits, bitstring, bytes, float,
integer, utf8, utf16, utf32
signed, unsigned
iex(1)> <<f::float, i::[size(32), signed]>> = <<64, 6, 102,
102, 102, 102, 102, 102, 255, 255, 254, 195>>
<<64, 6, 102, 102, 102, 102, 102, 102, 255, 255, 254, 195>>
iex(2)> f
2.8
iex(3)> i
-317
defmodule Test do
def circle(t) do
[x|tail] = t
tail ++ [x]
end
end
Test.circle [1, 2, 3]
# => [2, 3, 1]
defmodule Test do
def circle(t) do
[x|tail] = t
tail ++ [x]
end
end
Test.circle "123"
** (MatchError) no match of right
hand side value: "123"
defmodule Test do
def circle(t) when is_list(t) do
[x|tail] = t
tail ++ [x]
end
end
Test.circle [1, 2, 3]
# => [2, 3, 1]
defmodule Test do
def circle(t) when is_list(t) do
[x|tail] = t
tail ++ [x]
end
end
Test.circle "123"
** (FunctionClauseError) no function
clause matching in Test.circle/1
defmodule Test do
def circle([x|tail]) do
tail ++ [x]
end
end
Test.circle [1, 2, 3]
# => [2, 3, 1]
defmodule Test do
def circle([x|tail]) do
tail ++ [x]
end
end
Test.circle "123"
** (FunctionClauseError) no function
clause matching in Test.circle/1
defprotocol Test do
def circle(l)
end
defprotocol Test do
def circle(l)
end
defimpl Test, for: List do
def circle(l) do
[x|tail] = l
tail ++ [x]
end
end
defprotocol Test do
def circle(l)
end
defimpl Test, for: List do
def circle(l) do
[x|tail] = l
tail ++ [x]
end
end
Test.circle([1, 2, 3])
#=> [2, 3, 1]
Test.circle("123")
** (UndefinedFunctionError) undefined
function: Test.BitString.circle/1
Test.circle("123")
** (UndefinedFunctionError) undefined
function: Test.BitString.circle/1
defimpl Test, for: BitString do
def circle(l) do
[x|tail] = String.to_char_list!(l)
list_to_bitstring(tail ++ [x])
end
end
Test.circle("123")
** (UndefinedFunctionError) undefined
function: Test.BitString.circle/1
defimpl Test, for: BitString do
def circle(l) do
[x|tail] = String.to_char_list!(l)
list_to_bitstring(tail ++ [x])
end
end
Test.circle("123")
#=> "231"
defmodule Test do
defmacro times(n, body) do
quote do:
Enum.each(
1..unquote(n),
fn(_) -> unquote(body) end
)
end
end
require Test
Test.times(10) do
IO.puts "hello"
end
# => hello 10 times
Process
defmodule Math do
def sum do
receive do
{:sum, a, b} ->
IO.puts "#{a} + #{b} = #{a+b}"
sum()
_ -> IO.puts "not implemented!"
end
end
end
pid = spawn(fn -> Math.sum end)
pid <- {:sum, 4, 7}
# => 4 + 7 = 11
pid <- {:mult, 4, 7}
# => not implemented!
|>
x = [1, 2, 3, 4]
x = Enum.filter(x, fn(e) -> rem(e, 2) == 0 end)
x = Enum.reduce(x, 0, fn(e, r) -> e + r end)
|>
x = [1, 2, 3, 4]
x = Enum.filter(x, fn(e) -> rem(e, 2) == 0 end)
x = Enum.reduce(x, 0, fn(e, r) -> e + r end)
x = [1, 2, 3, 4]
|> Enum.filter(fn(e) -> rem(e, 2) == 0 end)
|> Enum.reduce(0, fn(e, r) -> e + r end)
|>
x = [1, 2, 3, 4]
x = Enum.filter(x, fn(e) -> rem(e, 2) == 0 end)
x = Enum.reduce(x, 0, fn(e, r) -> e + r end)
x = [1, 2, 3, 4]
|> Enum.filter(fn(e) -> rem(e, 2) == 0 end)
|> Enum.reduce(0, fn(e, r) -> e + r end)
x = [1, 2, 3, 4]
|> Enum.filter(&(rem(&1, 2) == 0))
|> Enum.reduce(0, &(&1 + &2))
Mix
mix new my_app
cd my_app
mix deps.get
mix compile
mix test
Web
• cowboy : http://ninenines.eu
• dynamo : https://github.com/elixir-lang/dynamo
• weber : http://0xax.github.io/weber/
Resources
http://elixir-lang.org
https://github.com/glejeune/ews
Elixir @ Paris.rb

More Related Content

What's hot

Bytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreterBytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreterakaptur
 
"PostgreSQL and Python" Lightning Talk @EuroPython2014
"PostgreSQL and Python" Lightning Talk @EuroPython2014"PostgreSQL and Python" Lightning Talk @EuroPython2014
"PostgreSQL and Python" Lightning Talk @EuroPython2014Henning Jacobs
 
LvivPy4 - Threading vs asyncio
LvivPy4 - Threading vs asyncioLvivPy4 - Threading vs asyncio
LvivPy4 - Threading vs asyncioRoman Rader
 
大量地区化解决方案V5
大量地区化解决方案V5大量地区化解决方案V5
大量地区化解决方案V5bqconf
 
Basic ASM by @binaryheadache
Basic ASM by @binaryheadacheBasic ASM by @binaryheadache
Basic ASM by @binaryheadachecamsec
 
Extreme JavaScript Performance
Extreme JavaScript PerformanceExtreme JavaScript Performance
Extreme JavaScript PerformanceThomas Fuchs
 
Python postgre sql a wonderful wedding
Python postgre sql   a wonderful weddingPython postgre sql   a wonderful wedding
Python postgre sql a wonderful weddingStéphane Wirtel
 
Load-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADLoad-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADDharmalingam Ganesan
 
Build a compiler in 2hrs - NCrafts Paris 2015
Build a compiler in 2hrs -  NCrafts Paris 2015Build a compiler in 2hrs -  NCrafts Paris 2015
Build a compiler in 2hrs - NCrafts Paris 2015Phillip Trelford
 
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPythonByterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPythonakaptur
 
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!..."A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...akaptur
 
Асинхронность и многопоточность в Яндекс.Такси — Дмитрий Курилов
Асинхронность и многопоточность в Яндекс.Такси — Дмитрий КуриловАсинхронность и многопоточность в Яндекс.Такси — Дмитрий Курилов
Асинхронность и многопоточность в Яндекс.Такси — Дмитрий КуриловYandex
 
start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()Kiwamu Okabe
 
/Root/exam unidad1/muestraip red
/Root/exam unidad1/muestraip red/Root/exam unidad1/muestraip red
/Root/exam unidad1/muestraip redAntonioAlejoAquino
 
The Ring programming language version 1.5.4 book - Part 47 of 185
The Ring programming language version 1.5.4 book - Part 47 of 185The Ring programming language version 1.5.4 book - Part 47 of 185
The Ring programming language version 1.5.4 book - Part 47 of 185Mahmoud Samir Fayed
 
Python sqlite3 - flask
Python   sqlite3 - flaskPython   sqlite3 - flask
Python sqlite3 - flaskEueung Mulyana
 
EcmaScript unchained
EcmaScript unchainedEcmaScript unchained
EcmaScript unchainedEduard Tomàs
 

What's hot (20)

Bytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreterBytes in the Machine: Inside the CPython interpreter
Bytes in the Machine: Inside the CPython interpreter
 
"PostgreSQL and Python" Lightning Talk @EuroPython2014
"PostgreSQL and Python" Lightning Talk @EuroPython2014"PostgreSQL and Python" Lightning Talk @EuroPython2014
"PostgreSQL and Python" Lightning Talk @EuroPython2014
 
LvivPy4 - Threading vs asyncio
LvivPy4 - Threading vs asyncioLvivPy4 - Threading vs asyncio
LvivPy4 - Threading vs asyncio
 
大量地区化解决方案V5
大量地区化解决方案V5大量地区化解决方案V5
大量地区化解决方案V5
 
Basic ASM by @binaryheadache
Basic ASM by @binaryheadacheBasic ASM by @binaryheadache
Basic ASM by @binaryheadache
 
Extreme JavaScript Performance
Extreme JavaScript PerformanceExtreme JavaScript Performance
Extreme JavaScript Performance
 
Python postgre sql a wonderful wedding
Python postgre sql   a wonderful weddingPython postgre sql   a wonderful wedding
Python postgre sql a wonderful wedding
 
Basics
BasicsBasics
Basics
 
Load-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADLoad-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOAD
 
Python 1 liners
Python 1 linersPython 1 liners
Python 1 liners
 
Build a compiler in 2hrs - NCrafts Paris 2015
Build a compiler in 2hrs -  NCrafts Paris 2015Build a compiler in 2hrs -  NCrafts Paris 2015
Build a compiler in 2hrs - NCrafts Paris 2015
 
Meck
MeckMeck
Meck
 
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPythonByterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
 
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!..."A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
 
Асинхронность и многопоточность в Яндекс.Такси — Дмитрий Курилов
Асинхронность и многопоточность в Яндекс.Такси — Дмитрий КуриловАсинхронность и многопоточность в Яндекс.Такси — Дмитрий Курилов
Асинхронность и многопоточность в Яндекс.Такси — Дмитрий Курилов
 
start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()
 
/Root/exam unidad1/muestraip red
/Root/exam unidad1/muestraip red/Root/exam unidad1/muestraip red
/Root/exam unidad1/muestraip red
 
The Ring programming language version 1.5.4 book - Part 47 of 185
The Ring programming language version 1.5.4 book - Part 47 of 185The Ring programming language version 1.5.4 book - Part 47 of 185
The Ring programming language version 1.5.4 book - Part 47 of 185
 
Python sqlite3 - flask
Python   sqlite3 - flaskPython   sqlite3 - flask
Python sqlite3 - flask
 
EcmaScript unchained
EcmaScript unchainedEcmaScript unchained
EcmaScript unchained
 

Viewers also liked

Petite introduction aux expressions rationnelles
Petite introduction aux expressions rationnellesPetite introduction aux expressions rationnelles
Petite introduction aux expressions rationnellesGregoire Lejeune
 
Teaching Students with Emojis, Emoticons, & Textspeak
Teaching Students with Emojis, Emoticons, & TextspeakTeaching Students with Emojis, Emoticons, & Textspeak
Teaching Students with Emojis, Emoticons, & TextspeakShelly Sanchez Terrell
 
UX, ethnography and possibilities: for Libraries, Museums and Archives
UX, ethnography and possibilities: for Libraries, Museums and ArchivesUX, ethnography and possibilities: for Libraries, Museums and Archives
UX, ethnography and possibilities: for Libraries, Museums and ArchivesNed Potter
 
Designing Teams for Emerging Challenges
Designing Teams for Emerging ChallengesDesigning Teams for Emerging Challenges
Designing Teams for Emerging ChallengesAaron Irizarry
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with DataSeth Familian
 
3 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 20173 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 2017Drift
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheLeslie Samuel
 
Retour d’expérience - Architecture MicroService chez BotsUnit
Retour d’expérience - Architecture MicroService chez BotsUnitRetour d’expérience - Architecture MicroService chez BotsUnit
Retour d’expérience - Architecture MicroService chez BotsUnitGregoire Lejeune
 
Health and Well-Being on the Social Web
Health and Well-Being on the Social WebHealth and Well-Being on the Social Web
Health and Well-Being on the Social Webron mader
 
DESIGN THE PRIORITY, PERFORMANCE 
AND UX
DESIGN THE PRIORITY, PERFORMANCE 
AND UXDESIGN THE PRIORITY, PERFORMANCE 
AND UX
DESIGN THE PRIORITY, PERFORMANCE 
AND UXPeter Rozek
 
Node.js and The Internet of Things
Node.js and The Internet of ThingsNode.js and The Internet of Things
Node.js and The Internet of ThingsLosant
 
How Much Further Will Internet Stocks Fall? (Share Price Performance)
How Much Further Will Internet Stocks Fall? (Share Price Performance)How Much Further Will Internet Stocks Fall? (Share Price Performance)
How Much Further Will Internet Stocks Fall? (Share Price Performance)Mahesh Vellanki
 
Net neutrality: The Basics
Net neutrality: The BasicsNet neutrality: The Basics
Net neutrality: The BasicsInterQuest Group
 
Finding Our Happy Place in the Internet of Things
Finding Our Happy Place in the Internet of ThingsFinding Our Happy Place in the Internet of Things
Finding Our Happy Place in the Internet of ThingsPamela Pavliscak
 
Internet of Things - The Tip of an Iceberg
Internet of Things - The Tip of an IcebergInternet of Things - The Tip of an Iceberg
Internet of Things - The Tip of an IcebergDr. Mazlan Abbas
 
Introduction to Development for the Internet
Introduction to Development for the InternetIntroduction to Development for the Internet
Introduction to Development for the InternetMike Crabb
 
Montreal Girl Geeks: Building the Modern Web
Montreal Girl Geeks: Building the Modern WebMontreal Girl Geeks: Building the Modern Web
Montreal Girl Geeks: Building the Modern WebRachel Andrew
 

Viewers also liked (20)

Leap parisrb
Leap parisrbLeap parisrb
Leap parisrb
 
Ruby et Rails
Ruby et RailsRuby et Rails
Ruby et Rails
 
Petite introduction aux expressions rationnelles
Petite introduction aux expressions rationnellesPetite introduction aux expressions rationnelles
Petite introduction aux expressions rationnelles
 
Teaching Students with Emojis, Emoticons, & Textspeak
Teaching Students with Emojis, Emoticons, & TextspeakTeaching Students with Emojis, Emoticons, & Textspeak
Teaching Students with Emojis, Emoticons, & Textspeak
 
UX, ethnography and possibilities: for Libraries, Museums and Archives
UX, ethnography and possibilities: for Libraries, Museums and ArchivesUX, ethnography and possibilities: for Libraries, Museums and Archives
UX, ethnography and possibilities: for Libraries, Museums and Archives
 
Designing Teams for Emerging Challenges
Designing Teams for Emerging ChallengesDesigning Teams for Emerging Challenges
Designing Teams for Emerging Challenges
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with Data
 
3 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 20173 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 2017
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
 
Retour d’expérience - Architecture MicroService chez BotsUnit
Retour d’expérience - Architecture MicroService chez BotsUnitRetour d’expérience - Architecture MicroService chez BotsUnit
Retour d’expérience - Architecture MicroService chez BotsUnit
 
Health and Well-Being on the Social Web
Health and Well-Being on the Social WebHealth and Well-Being on the Social Web
Health and Well-Being on the Social Web
 
Valentine's Day
Valentine's DayValentine's Day
Valentine's Day
 
DESIGN THE PRIORITY, PERFORMANCE 
AND UX
DESIGN THE PRIORITY, PERFORMANCE 
AND UXDESIGN THE PRIORITY, PERFORMANCE 
AND UX
DESIGN THE PRIORITY, PERFORMANCE 
AND UX
 
Node.js and The Internet of Things
Node.js and The Internet of ThingsNode.js and The Internet of Things
Node.js and The Internet of Things
 
How Much Further Will Internet Stocks Fall? (Share Price Performance)
How Much Further Will Internet Stocks Fall? (Share Price Performance)How Much Further Will Internet Stocks Fall? (Share Price Performance)
How Much Further Will Internet Stocks Fall? (Share Price Performance)
 
Net neutrality: The Basics
Net neutrality: The BasicsNet neutrality: The Basics
Net neutrality: The Basics
 
Finding Our Happy Place in the Internet of Things
Finding Our Happy Place in the Internet of ThingsFinding Our Happy Place in the Internet of Things
Finding Our Happy Place in the Internet of Things
 
Internet of Things - The Tip of an Iceberg
Internet of Things - The Tip of an IcebergInternet of Things - The Tip of an Iceberg
Internet of Things - The Tip of an Iceberg
 
Introduction to Development for the Internet
Introduction to Development for the InternetIntroduction to Development for the Internet
Introduction to Development for the Internet
 
Montreal Girl Geeks: Building the Modern Web
Montreal Girl Geeks: Building the Modern WebMontreal Girl Geeks: Building the Modern Web
Montreal Girl Geeks: Building the Modern Web
 

Similar to Elixir @ Paris.rb

ClojurianからみたElixir
ClojurianからみたElixirClojurianからみたElixir
ClojurianからみたElixirKent Ohashi
 
Introducción a Elixir
Introducción a ElixirIntroducción a Elixir
Introducción a ElixirSvet Ivantchev
 
Continuation Passing Style and Macros in Clojure - Jan 2012
Continuation Passing Style and Macros in Clojure - Jan 2012Continuation Passing Style and Macros in Clojure - Jan 2012
Continuation Passing Style and Macros in Clojure - Jan 2012Leonardo Borges
 
[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2Kevin Chun-Hsien Hsu
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Introthnetos
 
The Ring programming language version 1.5 book - Part 5 of 31
The Ring programming language version 1.5 book - Part 5 of 31The Ring programming language version 1.5 book - Part 5 of 31
The Ring programming language version 1.5 book - Part 5 of 31Mahmoud Samir Fayed
 
Ruby19 osdc-090418222718-phpapp02
Ruby19 osdc-090418222718-phpapp02Ruby19 osdc-090418222718-phpapp02
Ruby19 osdc-090418222718-phpapp02Apoorvi Kapoor
 
Clojure 1.1 And Beyond
Clojure 1.1 And BeyondClojure 1.1 And Beyond
Clojure 1.1 And BeyondMike Fogus
 
Python fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuanPython fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuanWei-Yuan Chang
 
Functional Operations - Susan Potter
Functional Operations - Susan PotterFunctional Operations - Susan Potter
Functional Operations - Susan Potterdistributed matters
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghStuart Roebuck
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015Michiel Borkent
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Ruby - Uma Introdução
Ruby - Uma IntroduçãoRuby - Uma Introdução
Ruby - Uma IntroduçãoÍgor Bonadio
 
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate CompilersFunctional Thursday
 
Gabriele Lana - The Magic of Elixir
Gabriele Lana - The Magic of ElixirGabriele Lana - The Magic of Elixir
Gabriele Lana - The Magic of ElixirCodemotion
 

Similar to Elixir @ Paris.rb (20)

ClojurianからみたElixir
ClojurianからみたElixirClojurianからみたElixir
ClojurianからみたElixir
 
Introducción a Elixir
Introducción a ElixirIntroducción a Elixir
Introducción a Elixir
 
FPBrno 2018-05-22: Benchmarking in elixir
FPBrno 2018-05-22: Benchmarking in elixirFPBrno 2018-05-22: Benchmarking in elixir
FPBrno 2018-05-22: Benchmarking in elixir
 
Continuation Passing Style and Macros in Clojure - Jan 2012
Continuation Passing Style and Macros in Clojure - Jan 2012Continuation Passing Style and Macros in Clojure - Jan 2012
Continuation Passing Style and Macros in Clojure - Jan 2012
 
[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2
 
Clojure Intro
Clojure IntroClojure Intro
Clojure Intro
 
The Ring programming language version 1.5 book - Part 5 of 31
The Ring programming language version 1.5 book - Part 5 of 31The Ring programming language version 1.5 book - Part 5 of 31
The Ring programming language version 1.5 book - Part 5 of 31
 
Ruby19 osdc-090418222718-phpapp02
Ruby19 osdc-090418222718-phpapp02Ruby19 osdc-090418222718-phpapp02
Ruby19 osdc-090418222718-phpapp02
 
Ruby 1.9
Ruby 1.9Ruby 1.9
Ruby 1.9
 
Clojure 1.1 And Beyond
Clojure 1.1 And BeyondClojure 1.1 And Beyond
Clojure 1.1 And Beyond
 
ES6: Features + Rails
ES6: Features + RailsES6: Features + Rails
ES6: Features + Rails
 
Python fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuanPython fundamentals - basic | WeiYuan
Python fundamentals - basic | WeiYuan
 
Functional Operations - Susan Potter
Functional Operations - Susan PotterFunctional Operations - Susan Potter
Functional Operations - Susan Potter
 
Javascript
JavascriptJavascript
Javascript
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Ruby - Uma Introdução
Ruby - Uma IntroduçãoRuby - Uma Introdução
Ruby - Uma Introdução
 
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
 
Gabriele Lana - The Magic of Elixir
Gabriele Lana - The Magic of ElixirGabriele Lana - The Magic of Elixir
Gabriele Lana - The Magic of Elixir
 

Recently uploaded

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Recently uploaded (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

Elixir @ Paris.rb

  • 2. Elixir José Valim - co-fondateur de Plataformatec (http://plataformatec.com.br) Proposer la puissance de la machine virtuelle Erlang d’une manière différente aux développeurs. Premier commit date de janvier 2011 Version actuelle : 0.10.2 / 0.10.3-dev Release finale est prévue pour juin 2014
  • 3. Erlang : wget http://www.erlang.org/download/otp_src_R16B02.tar.gz tar zxf otp_src_R16B02.tar.gz cd otp_src_R16B02 ./configure make sudo make install Elixir : git clone https://github.com/elixir-lang/elixir.git cd elixir make sudo make install
  • 4. Les variables Erlang : • /^(?:_[a-zA-Z0-9_]|[A-Z])[a-zA-Z0-9_]*$/ • single assignment Elixir : • /^(?:_[a-zA-Z0-9_]|[a-z])[a-zA-Z0-9_]*$/ • re assignment
  • 5. Erlang : 1> A = [1, 2, 3]. [1, 2, 3] 2> A = [4, 5, 6]. ** exception error: no match of right hand side value [4,5,6] Elixir : iex(1)> a = [1, 2, 3] [1, 2, 3] iex(2)> a = [4, 5, 6] [4, 5, 6] Les variables
  • 6. iex(1)> a = [1, 2, 3] [1, 2, 3] iex(2)> [b, c, d] = a [1, 2, 3] iex(3)> b 1 iex(4)> c 2 iex(4)> d 3
  • 7. iex(1)> a = [1, 2, 3] [1, 2, 3] iex(2)> [b | tail] = a [1, 2, 3] iex(3)> b 1 iex(4)> tail [2, 3]
  • 8. atomes :an_atom :"an atom!" booléens true false listes [104,101,108,108,111] = ‘hello’ tuples {1, :tuple, ‘de’, "données"}
  • 9. fonctions my_fun = fn(x) -> x*x end my_fun.(3) regex %r/erlang|elixir/ range [1..10] hash [key1: "value1", key2: 3, ...] [{"Une clé", "sa valeur»}, ...]
  • 10. Les binaires : séquence d’entiers (0-255 / 8 bits) placée entre << et >>
  • 11. Les binaires : séquence d’entiers (0-255 / 8 bits) placée entre << et >> <<104, 101, 108, 108, 111>>
  • 12. Les binaires : séquence d’entiers (0-255 / 8 bits) placée entre << et >> <<[104, 101, 108, 108, 111]>> <<104, 101, 108, 108, 111>>
  • 13. Les binaires : séquence d’entiers (0-255 / 8 bits) placée entre << et >> <<[104, 101, 108, 108, 111]>> <<'hello'>> <<104, 101, 108, 108, 111>>
  • 14. Les binaires : séquence d’entiers (0-255 / 8 bits) placée entre << et >> <<[104, 101, 108, 108, 111]>> <<'hello'>> "hello" <<104, 101, 108, 108, 111>>
  • 18. <<259>> = <<3>> <<259:size(16)>> = <<1, 3>> <<x:size(16)>> = <<1, 3>>
  • 20. <<2.4>> ** (ArgumentError) argument error :erl_eval.expr/3
  • 21. <<2.4>> <<2.4:float>> = <<64, 3, 51, 51, 51, 51, 51, 51>> ** (ArgumentError) argument error :erl_eval.expr/3
  • 22. <<2.4>> <<2.4:float>> = <<64, 3, 51, 51, 51, 51, 51, 51>> ** (ArgumentError) argument error :erl_eval.expr/3 les flottants sont codés sur 64 bits ; le premier bit pour coder le signe, les 11 suivants pour l’exposant, puis 52 bits pour la mantisse et le dernier, implicite.
  • 23. binary, bits, bitstring, bytes, float, integer, utf8, utf16, utf32 signed, unsigned iex(1)> <<f::float, i::[size(32), signed]>> = <<64, 6, 102, 102, 102, 102, 102, 102, 255, 255, 254, 195>> <<64, 6, 102, 102, 102, 102, 102, 102, 255, 255, 254, 195>> iex(2)> f 2.8 iex(3)> i -317
  • 24. defmodule Test do def circle(t) do [x|tail] = t tail ++ [x] end end Test.circle [1, 2, 3] # => [2, 3, 1]
  • 25. defmodule Test do def circle(t) do [x|tail] = t tail ++ [x] end end Test.circle "123" ** (MatchError) no match of right hand side value: "123"
  • 26. defmodule Test do def circle(t) when is_list(t) do [x|tail] = t tail ++ [x] end end Test.circle [1, 2, 3] # => [2, 3, 1]
  • 27. defmodule Test do def circle(t) when is_list(t) do [x|tail] = t tail ++ [x] end end Test.circle "123" ** (FunctionClauseError) no function clause matching in Test.circle/1
  • 28. defmodule Test do def circle([x|tail]) do tail ++ [x] end end Test.circle [1, 2, 3] # => [2, 3, 1]
  • 29. defmodule Test do def circle([x|tail]) do tail ++ [x] end end Test.circle "123" ** (FunctionClauseError) no function clause matching in Test.circle/1
  • 30. defprotocol Test do def circle(l) end
  • 31. defprotocol Test do def circle(l) end defimpl Test, for: List do def circle(l) do [x|tail] = l tail ++ [x] end end
  • 32. defprotocol Test do def circle(l) end defimpl Test, for: List do def circle(l) do [x|tail] = l tail ++ [x] end end Test.circle([1, 2, 3]) #=> [2, 3, 1]
  • 34. Test.circle("123") ** (UndefinedFunctionError) undefined function: Test.BitString.circle/1 defimpl Test, for: BitString do def circle(l) do [x|tail] = String.to_char_list!(l) list_to_bitstring(tail ++ [x]) end end
  • 35. Test.circle("123") ** (UndefinedFunctionError) undefined function: Test.BitString.circle/1 defimpl Test, for: BitString do def circle(l) do [x|tail] = String.to_char_list!(l) list_to_bitstring(tail ++ [x]) end end Test.circle("123") #=> "231"
  • 36. defmodule Test do defmacro times(n, body) do quote do: Enum.each( 1..unquote(n), fn(_) -> unquote(body) end ) end end require Test Test.times(10) do IO.puts "hello" end # => hello 10 times
  • 37. Process defmodule Math do def sum do receive do {:sum, a, b} -> IO.puts "#{a} + #{b} = #{a+b}" sum() _ -> IO.puts "not implemented!" end end end pid = spawn(fn -> Math.sum end) pid <- {:sum, 4, 7} # => 4 + 7 = 11 pid <- {:mult, 4, 7} # => not implemented!
  • 38. |> x = [1, 2, 3, 4] x = Enum.filter(x, fn(e) -> rem(e, 2) == 0 end) x = Enum.reduce(x, 0, fn(e, r) -> e + r end)
  • 39. |> x = [1, 2, 3, 4] x = Enum.filter(x, fn(e) -> rem(e, 2) == 0 end) x = Enum.reduce(x, 0, fn(e, r) -> e + r end) x = [1, 2, 3, 4] |> Enum.filter(fn(e) -> rem(e, 2) == 0 end) |> Enum.reduce(0, fn(e, r) -> e + r end)
  • 40. |> x = [1, 2, 3, 4] x = Enum.filter(x, fn(e) -> rem(e, 2) == 0 end) x = Enum.reduce(x, 0, fn(e, r) -> e + r end) x = [1, 2, 3, 4] |> Enum.filter(fn(e) -> rem(e, 2) == 0 end) |> Enum.reduce(0, fn(e, r) -> e + r end) x = [1, 2, 3, 4] |> Enum.filter(&(rem(&1, 2) == 0)) |> Enum.reduce(0, &(&1 + &2))
  • 41. Mix mix new my_app cd my_app mix deps.get mix compile mix test
  • 42. Web • cowboy : http://ninenines.eu • dynamo : https://github.com/elixir-lang/dynamo • weber : http://0xax.github.io/weber/