SlideShare a Scribd company logo
1 of 17
Download to read offline
Elixir紹介
2014/05/08
SICP Club LT
Livesense Inc.
HORINOUCHI Masato
Elixirとは
Elixir is a func-onal, meta-programming aware language built on
top of the Erlang VM. It is a dynamic language that focuses on
tooling to leverage Erlang's abili-es to build concurrent, distributed
and fault-tolerant applica-ons with hot code upgrades.
見た目は
Ruby
中身は
Lisp
特徴
• 近代的なシンタックス
• 全てが式
• 強力なメタプログラミング機能
• 第一級オブジェクトとしてのドキュメント
• Erlangランタイムとの相互運用
Fibonacci (Ruby)
class Fib
def self.fib n
case n
when 0 then 0
when 1 then 1
else fib(n - 1) + fib(n - 2)
end
end
end
puts Fib.fib 10
Fibonacci (Elixir)
defmodule Fib do
def fib(0), do: 1
def fib(1), do: 1
def fib(n), do: fib(n-1) + fib(n-2)
end
IO.puts Fib.fib 6
Install
• OS X (homebrew)
• $ brew install erlang –devel
• $ brew install elixir
• Windows
• なんか大変らしい
• Ubuntu
• PPA あるよ
REPL
$ iex
iex> defmodule Hello do
...> def world do
...> IO.puts "Hello, world"
...> end
...> end
iex> Hello.world
Hello, world
:ok
iex>
無名関数
iex> f = fn(x) -> x * 2 end
iex> f.(4)
8
iex> (fn(x) -> x * 3 end).(3)
9
map reduce
iex> Enum.map(
...> [1,2,3],
...> fn(x) -> x * 2 end)
[2, 4, 6]
iex> Enum.reduce(
...> [1,2,3],
...> fn(x, acc) -> x + acc end)
6
キーワード引数と括弧の省略
iex> if true do
...> 1
...> else
...> 2
...> end
1
iex> if true, do: 1, else: 2
1
iex> if true, [do: 1, else: 2]
1
iex> if(true, [do: 1, else: 2])
1
Homoiconicity
In a homoiconic language the primary representa3on of programs is
also a data structure in a primi3ve type of the language itself. This
makes metaprogramming easier than in a language without this
property, since code can be treated as data: reflec3on in the
language (examining the program's en33es at run3me) depends on
a single, homogeneous structure, and it does not have to handle
several different structures that would appear in a complex syntax.
To put that another way, homoiconicity is where a program's source
code is wriDen as a basic data structure that the programming
language knows how to access.
quote
iex> length [1,2,3]
3
iex> quote do: length [1,2,3]
{:length, [context: Elixir, import: Kernel], [[1, 2, 3]]}
iex> 1 + 2
3
iex> quote do: 1 + 2
{:+, [context: Elixir, import: Kernel], [1, 2]}
macro
iex> defmodule MyUnless do
...> defmacro unless(clause, options) do
...> quote do: if !unquote(clause),
...> unquote(options)
...> end
...> end
iex> require MyUnless
nil
Iex> MyUnless.unless true, do: 1, else: 2
2
defmacro if
defmacro if(condition, clauses) do
do_clause = Keyword.get(clauses, :do, nil)
else_clause = Keyword.get(clauses, :else, nil)
quote do
case unquote(condition) do
_ in [false, nil] -> unquote(else_clause)
_ -> unquote(do_clause)
end
end
end
if すらもマクロ
ご清聴ありがとうございました

More Related Content

What's hot

Textual programming in key stage 3
Textual programming in key stage 3Textual programming in key stage 3
Textual programming in key stage 3eaglestone
 
VB.NET:An introduction to Namespaces in .NET framework
VB.NET:An introduction to  Namespaces in .NET frameworkVB.NET:An introduction to  Namespaces in .NET framework
VB.NET:An introduction to Namespaces in .NET frameworkRicha Handa
 
web programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Malothweb programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh MalothBhavsingh Maloth
 
Before Starting Python Programming Language
Before Starting Python Programming LanguageBefore Starting Python Programming Language
Before Starting Python Programming LanguageKishan Tongrao
 
.Net framework components by naveen kumar veligeti
.Net framework components by naveen kumar veligeti.Net framework components by naveen kumar veligeti
.Net framework components by naveen kumar veligetiNaveen Kumar Veligeti
 
Elixir's Object Oriented Layer
Elixir's Object Oriented LayerElixir's Object Oriented Layer
Elixir's Object Oriented LayerPaolo Montrasio
 
Introduction To Python | Edureka
Introduction To Python | EdurekaIntroduction To Python | Edureka
Introduction To Python | EdurekaEdureka!
 
Presentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStackPresentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStackDavid Sanchez
 
Introduction about Python by JanBask Training
Introduction about Python by JanBask TrainingIntroduction about Python by JanBask Training
Introduction about Python by JanBask TrainingJanBask Training
 
Socket Programming In Python
Socket Programming In PythonSocket Programming In Python
Socket Programming In Pythondidip
 
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTHBhavsingh Maloth
 
GDG Helwan Introduction to python
GDG Helwan Introduction to pythonGDG Helwan Introduction to python
GDG Helwan Introduction to pythonMohamed Hegazy
 
Erlang - Concurrent Language for Concurrent World
Erlang - Concurrent Language for Concurrent WorldErlang - Concurrent Language for Concurrent World
Erlang - Concurrent Language for Concurrent WorldZvi Avraham
 
Pharo foreign function interface (FFI) by example by Esteban Lorenzano
Pharo foreign function interface (FFI) by example by Esteban LorenzanoPharo foreign function interface (FFI) by example by Esteban Lorenzano
Pharo foreign function interface (FFI) by example by Esteban LorenzanoFAST
 
Python final presentation kirti ppt1
Python final presentation kirti ppt1Python final presentation kirti ppt1
Python final presentation kirti ppt1Kirti Verma
 

What's hot (20)

Textual programming in key stage 3
Textual programming in key stage 3Textual programming in key stage 3
Textual programming in key stage 3
 
VB.NET:An introduction to Namespaces in .NET framework
VB.NET:An introduction to  Namespaces in .NET frameworkVB.NET:An introduction to  Namespaces in .NET framework
VB.NET:An introduction to Namespaces in .NET framework
 
LIL Presentation
LIL PresentationLIL Presentation
LIL Presentation
 
Python - Lesson 1
Python - Lesson 1Python - Lesson 1
Python - Lesson 1
 
web programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Malothweb programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Maloth
 
Create Your Own Language
Create Your Own LanguageCreate Your Own Language
Create Your Own Language
 
Before Starting Python Programming Language
Before Starting Python Programming LanguageBefore Starting Python Programming Language
Before Starting Python Programming Language
 
.Net framework components by naveen kumar veligeti
.Net framework components by naveen kumar veligeti.Net framework components by naveen kumar veligeti
.Net framework components by naveen kumar veligeti
 
Python Tutorial for Beginner
Python Tutorial for BeginnerPython Tutorial for Beginner
Python Tutorial for Beginner
 
Programming
ProgrammingProgramming
Programming
 
Elixir's Object Oriented Layer
Elixir's Object Oriented LayerElixir's Object Oriented Layer
Elixir's Object Oriented Layer
 
Introduction To Python | Edureka
Introduction To Python | EdurekaIntroduction To Python | Edureka
Introduction To Python | Edureka
 
Presentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStackPresentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStack
 
Introduction about Python by JanBask Training
Introduction about Python by JanBask TrainingIntroduction about Python by JanBask Training
Introduction about Python by JanBask Training
 
Socket Programming In Python
Socket Programming In PythonSocket Programming In Python
Socket Programming In Python
 
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT V BY BHAVSINGH MALOTH
 
GDG Helwan Introduction to python
GDG Helwan Introduction to pythonGDG Helwan Introduction to python
GDG Helwan Introduction to python
 
Erlang - Concurrent Language for Concurrent World
Erlang - Concurrent Language for Concurrent WorldErlang - Concurrent Language for Concurrent World
Erlang - Concurrent Language for Concurrent World
 
Pharo foreign function interface (FFI) by example by Esteban Lorenzano
Pharo foreign function interface (FFI) by example by Esteban LorenzanoPharo foreign function interface (FFI) by example by Esteban Lorenzano
Pharo foreign function interface (FFI) by example by Esteban Lorenzano
 
Python final presentation kirti ppt1
Python final presentation kirti ppt1Python final presentation kirti ppt1
Python final presentation kirti ppt1
 

Viewers also liked

A moving average analysis of the age distribution and
A moving average analysis of the age distribution andA moving average analysis of the age distribution and
A moving average analysis of the age distribution andAlexander Decker
 
أخطاء و ضلالات سيد قطب بالكتاب والصفحة و رد العلماء عليه
 أخطاء و ضلالات سيد قطب بالكتاب والصفحة و رد العلماء عليه  أخطاء و ضلالات سيد قطب بالكتاب والصفحة و رد العلماء عليه
أخطاء و ضلالات سيد قطب بالكتاب والصفحة و رد العلماء عليه ania amiis
 
Who’d be a parent - your role in drug and alcohol prevention
Who’d be a parent - your role in drug and alcohol prevention Who’d be a parent - your role in drug and alcohol prevention
Who’d be a parent - your role in drug and alcohol prevention Mentor
 
The Digital Garage Certification
The Digital Garage CertificationThe Digital Garage Certification
The Digital Garage CertificationStuart Seager
 
September 2010-President's List
September 2010-President's ListSeptember 2010-President's List
September 2010-President's ListLesley Johnson
 
学生、教職員が一線に並んで交流できる 「英語でビブリオバトル」
学生、教職員が一線に並んで交流できる 「英語でビブリオバトル」学生、教職員が一線に並んで交流できる 「英語でビブリオバトル」
学生、教職員が一線に並んで交流できる 「英語でビブリオバトル」Yukie KONDO
 

Viewers also liked (11)

A mathematical appraisal
A mathematical appraisalA mathematical appraisal
A mathematical appraisal
 
A moving average analysis of the age distribution and
A moving average analysis of the age distribution andA moving average analysis of the age distribution and
A moving average analysis of the age distribution and
 
Gresume0716
Gresume0716Gresume0716
Gresume0716
 
A440
A440A440
A440
 
أخطاء و ضلالات سيد قطب بالكتاب والصفحة و رد العلماء عليه
 أخطاء و ضلالات سيد قطب بالكتاب والصفحة و رد العلماء عليه  أخطاء و ضلالات سيد قطب بالكتاب والصفحة و رد العلماء عليه
أخطاء و ضلالات سيد قطب بالكتاب والصفحة و رد العلماء عليه
 
Who’d be a parent - your role in drug and alcohol prevention
Who’d be a parent - your role in drug and alcohol prevention Who’d be a parent - your role in drug and alcohol prevention
Who’d be a parent - your role in drug and alcohol prevention
 
Inside mml2wav.rb
Inside mml2wav.rbInside mml2wav.rb
Inside mml2wav.rb
 
The Digital Garage Certification
The Digital Garage CertificationThe Digital Garage Certification
The Digital Garage Certification
 
POSIX Threads
POSIX ThreadsPOSIX Threads
POSIX Threads
 
September 2010-President's List
September 2010-President's ListSeptember 2010-President's List
September 2010-President's List
 
学生、教職員が一線に並んで交流できる 「英語でビブリオバトル」
学生、教職員が一線に並んで交流できる 「英語でビブリオバトル」学生、教職員が一線に並んで交流できる 「英語でビブリオバトル」
学生、教職員が一線に並んで交流できる 「英語でビブリオバトル」
 

Similar to Elixir紹介

Programing paradigm & implementation
Programing paradigm & implementationPrograming paradigm & implementation
Programing paradigm & implementationBilal Maqbool ツ
 
OOP Comparative Study
OOP Comparative StudyOOP Comparative Study
OOP Comparative StudyDarren Tan
 
02 intro to programming in .net (part 2)
02   intro to programming in .net (part 2)02   intro to programming in .net (part 2)
02 intro to programming in .net (part 2)Felisha Hosein
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processorsRebaz Najeeb
 
BUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and ApproachesBUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and ApproachesLinaro
 
Technologies of today
Technologies of todayTechnologies of today
Technologies of todaykagecat
 
ICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.doc
ICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.docICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.doc
ICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.docAmanGunner
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word documentSIVAJISADHANA
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word documentSIVAJISADHANA
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word documentSIVAJISADHANA
 
DEF CON 23 - Saif el-sherei and etienne stalmans - fuzzing
DEF CON 23 - Saif el-sherei and etienne stalmans - fuzzingDEF CON 23 - Saif el-sherei and etienne stalmans - fuzzing
DEF CON 23 - Saif el-sherei and etienne stalmans - fuzzingFelipe Prado
 
Introduction To Computer Programming
Introduction To Computer ProgrammingIntroduction To Computer Programming
Introduction To Computer ProgrammingHussain Buksh
 
Compiler design
Compiler designCompiler design
Compiler designsanchi29
 
Welcome to the .Net
Welcome to the .NetWelcome to the .Net
Welcome to the .NetAmr Shawky
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programmingGwyneth Calica
 
Insight into progam execution ppt
Insight into progam execution pptInsight into progam execution ppt
Insight into progam execution pptKeerty Smile
 

Similar to Elixir紹介 (20)

Programing paradigm & implementation
Programing paradigm & implementationPrograming paradigm & implementation
Programing paradigm & implementation
 
Seeking Clojure
Seeking ClojureSeeking Clojure
Seeking Clojure
 
OOP Comparative Study
OOP Comparative StudyOOP Comparative Study
OOP Comparative Study
 
02 intro to programming in .net (part 2)
02   intro to programming in .net (part 2)02   intro to programming in .net (part 2)
02 intro to programming in .net (part 2)
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processors
 
BUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and ApproachesBUD17-104: Scripting Languages in IoT: Challenges and Approaches
BUD17-104: Scripting Languages in IoT: Challenges and Approaches
 
Technologies of today
Technologies of todayTechnologies of today
Technologies of today
 
Unit 1
Unit 1Unit 1
Unit 1
 
JAVA
JAVAJAVA
JAVA
 
ICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.doc
ICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.docICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.doc
ICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.doc
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
 
DEF CON 23 - Saif el-sherei and etienne stalmans - fuzzing
DEF CON 23 - Saif el-sherei and etienne stalmans - fuzzingDEF CON 23 - Saif el-sherei and etienne stalmans - fuzzing
DEF CON 23 - Saif el-sherei and etienne stalmans - fuzzing
 
Introduction To Computer Programming
Introduction To Computer ProgrammingIntroduction To Computer Programming
Introduction To Computer Programming
 
Compiler design
Compiler designCompiler design
Compiler design
 
Intro to Elixir talk
Intro to Elixir talkIntro to Elixir talk
Intro to Elixir talk
 
Welcome to the .Net
Welcome to the .NetWelcome to the .Net
Welcome to the .Net
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
 
Insight into progam execution ppt
Insight into progam execution pptInsight into progam execution ppt
Insight into progam execution ppt
 

More from Masato HORINOUCHI (6)

Church Numerals
Church NumeralsChurch Numerals
Church Numerals
 
CPS & CTO
CPS & CTOCPS & CTO
CPS & CTO
 
FM synthesis
FM synthesisFM synthesis
FM synthesis
 
Scheme Interpreter in Ruby
Scheme Interpreter in RubyScheme Interpreter in Ruby
Scheme Interpreter in Ruby
 
Clock / Timer
Clock / TimerClock / Timer
Clock / Timer
 
Hash Tree
Hash TreeHash Tree
Hash Tree
 

Recently uploaded

IT Service Management (ITSM) Best Practices for Advanced Computing
IT Service Management (ITSM) Best Practices for Advanced ComputingIT Service Management (ITSM) Best Practices for Advanced Computing
IT Service Management (ITSM) Best Practices for Advanced ComputingMAGNIntelligence
 
How to become a GDSC Lead GDSC MI AOE.pptx
How to become a GDSC Lead GDSC MI AOE.pptxHow to become a GDSC Lead GDSC MI AOE.pptx
How to become a GDSC Lead GDSC MI AOE.pptxKaustubhBhavsar6
 
3 Pitfalls Everyone Should Avoid with Cloud Data
3 Pitfalls Everyone Should Avoid with Cloud Data3 Pitfalls Everyone Should Avoid with Cloud Data
3 Pitfalls Everyone Should Avoid with Cloud DataEric D. Schabell
 
UiPath Studio Web workshop series - Day 2
UiPath Studio Web workshop series - Day 2UiPath Studio Web workshop series - Day 2
UiPath Studio Web workshop series - Day 2DianaGray10
 
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxGraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxNeo4j
 
My key hands-on projects in Quantum, and QAI
My key hands-on projects in Quantum, and QAIMy key hands-on projects in Quantum, and QAI
My key hands-on projects in Quantum, and QAIVijayananda Mohire
 
The Importance of Indoor Air Quality (English)
The Importance of Indoor Air Quality (English)The Importance of Indoor Air Quality (English)
The Importance of Indoor Air Quality (English)IES VE
 
UiPath Studio Web workshop series - Day 1
UiPath Studio Web workshop series  - Day 1UiPath Studio Web workshop series  - Day 1
UiPath Studio Web workshop series - Day 1DianaGray10
 
SIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENT
SIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENTSIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENT
SIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENTxtailishbaloch
 
Introduction to RAG (Retrieval Augmented Generation) and its application
Introduction to RAG (Retrieval Augmented Generation) and its applicationIntroduction to RAG (Retrieval Augmented Generation) and its application
Introduction to RAG (Retrieval Augmented Generation) and its applicationKnoldus Inc.
 
UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4DianaGray10
 
TrustArc Webinar - How to Live in a Post Third-Party Cookie World
TrustArc Webinar - How to Live in a Post Third-Party Cookie WorldTrustArc Webinar - How to Live in a Post Third-Party Cookie World
TrustArc Webinar - How to Live in a Post Third-Party Cookie WorldTrustArc
 
Oracle Database 23c Security New Features.pptx
Oracle Database 23c Security New Features.pptxOracle Database 23c Security New Features.pptx
Oracle Database 23c Security New Features.pptxSatishbabu Gunukula
 
20140402 - Smart house demo kit
20140402 - Smart house demo kit20140402 - Smart house demo kit
20140402 - Smart house demo kitJamie (Taka) Wang
 
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedInOutage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedInThousandEyes
 
EMEA What is ThousandEyes? Webinar
EMEA What is ThousandEyes? WebinarEMEA What is ThousandEyes? Webinar
EMEA What is ThousandEyes? WebinarThousandEyes
 
AI Workshops at Computers In Libraries 2024
AI Workshops at Computers In Libraries 2024AI Workshops at Computers In Libraries 2024
AI Workshops at Computers In Libraries 2024Brian Pichman
 
Trailblazer Community - Flows Workshop (Session 2)
Trailblazer Community - Flows Workshop (Session 2)Trailblazer Community - Flows Workshop (Session 2)
Trailblazer Community - Flows Workshop (Session 2)Muhammad Tiham Siddiqui
 
March Patch Tuesday
March Patch TuesdayMarch Patch Tuesday
March Patch TuesdayIvanti
 
How to release an Open Source Dataweave Library
How to release an Open Source Dataweave LibraryHow to release an Open Source Dataweave Library
How to release an Open Source Dataweave Libraryshyamraj55
 

Recently uploaded (20)

IT Service Management (ITSM) Best Practices for Advanced Computing
IT Service Management (ITSM) Best Practices for Advanced ComputingIT Service Management (ITSM) Best Practices for Advanced Computing
IT Service Management (ITSM) Best Practices for Advanced Computing
 
How to become a GDSC Lead GDSC MI AOE.pptx
How to become a GDSC Lead GDSC MI AOE.pptxHow to become a GDSC Lead GDSC MI AOE.pptx
How to become a GDSC Lead GDSC MI AOE.pptx
 
3 Pitfalls Everyone Should Avoid with Cloud Data
3 Pitfalls Everyone Should Avoid with Cloud Data3 Pitfalls Everyone Should Avoid with Cloud Data
3 Pitfalls Everyone Should Avoid with Cloud Data
 
UiPath Studio Web workshop series - Day 2
UiPath Studio Web workshop series - Day 2UiPath Studio Web workshop series - Day 2
UiPath Studio Web workshop series - Day 2
 
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxGraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
 
My key hands-on projects in Quantum, and QAI
My key hands-on projects in Quantum, and QAIMy key hands-on projects in Quantum, and QAI
My key hands-on projects in Quantum, and QAI
 
The Importance of Indoor Air Quality (English)
The Importance of Indoor Air Quality (English)The Importance of Indoor Air Quality (English)
The Importance of Indoor Air Quality (English)
 
UiPath Studio Web workshop series - Day 1
UiPath Studio Web workshop series  - Day 1UiPath Studio Web workshop series  - Day 1
UiPath Studio Web workshop series - Day 1
 
SIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENT
SIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENTSIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENT
SIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENT
 
Introduction to RAG (Retrieval Augmented Generation) and its application
Introduction to RAG (Retrieval Augmented Generation) and its applicationIntroduction to RAG (Retrieval Augmented Generation) and its application
Introduction to RAG (Retrieval Augmented Generation) and its application
 
UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4UiPath Studio Web workshop series - Day 4
UiPath Studio Web workshop series - Day 4
 
TrustArc Webinar - How to Live in a Post Third-Party Cookie World
TrustArc Webinar - How to Live in a Post Third-Party Cookie WorldTrustArc Webinar - How to Live in a Post Third-Party Cookie World
TrustArc Webinar - How to Live in a Post Third-Party Cookie World
 
Oracle Database 23c Security New Features.pptx
Oracle Database 23c Security New Features.pptxOracle Database 23c Security New Features.pptx
Oracle Database 23c Security New Features.pptx
 
20140402 - Smart house demo kit
20140402 - Smart house demo kit20140402 - Smart house demo kit
20140402 - Smart house demo kit
 
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedInOutage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
Outage Analysis: March 5th/6th 2024 Meta, Comcast, and LinkedIn
 
EMEA What is ThousandEyes? Webinar
EMEA What is ThousandEyes? WebinarEMEA What is ThousandEyes? Webinar
EMEA What is ThousandEyes? Webinar
 
AI Workshops at Computers In Libraries 2024
AI Workshops at Computers In Libraries 2024AI Workshops at Computers In Libraries 2024
AI Workshops at Computers In Libraries 2024
 
Trailblazer Community - Flows Workshop (Session 2)
Trailblazer Community - Flows Workshop (Session 2)Trailblazer Community - Flows Workshop (Session 2)
Trailblazer Community - Flows Workshop (Session 2)
 
March Patch Tuesday
March Patch TuesdayMarch Patch Tuesday
March Patch Tuesday
 
How to release an Open Source Dataweave Library
How to release an Open Source Dataweave LibraryHow to release an Open Source Dataweave Library
How to release an Open Source Dataweave Library
 

Elixir紹介

  • 2. Elixirとは Elixir is a func-onal, meta-programming aware language built on top of the Erlang VM. It is a dynamic language that focuses on tooling to leverage Erlang's abili-es to build concurrent, distributed and fault-tolerant applica-ons with hot code upgrades.
  • 4. 特徴 • 近代的なシンタックス • 全てが式 • 強力なメタプログラミング機能 • 第一級オブジェクトとしてのドキュメント • Erlangランタイムとの相互運用
  • 5. Fibonacci (Ruby) class Fib def self.fib n case n when 0 then 0 when 1 then 1 else fib(n - 1) + fib(n - 2) end end end puts Fib.fib 10
  • 6. Fibonacci (Elixir) defmodule Fib do def fib(0), do: 1 def fib(1), do: 1 def fib(n), do: fib(n-1) + fib(n-2) end IO.puts Fib.fib 6
  • 7. Install • OS X (homebrew) • $ brew install erlang –devel • $ brew install elixir • Windows • なんか大変らしい • Ubuntu • PPA あるよ
  • 8. REPL $ iex iex> defmodule Hello do ...> def world do ...> IO.puts "Hello, world" ...> end ...> end iex> Hello.world Hello, world :ok iex>
  • 9. 無名関数 iex> f = fn(x) -> x * 2 end iex> f.(4) 8 iex> (fn(x) -> x * 3 end).(3) 9
  • 10. map reduce iex> Enum.map( ...> [1,2,3], ...> fn(x) -> x * 2 end) [2, 4, 6] iex> Enum.reduce( ...> [1,2,3], ...> fn(x, acc) -> x + acc end) 6
  • 11. キーワード引数と括弧の省略 iex> if true do ...> 1 ...> else ...> 2 ...> end 1 iex> if true, do: 1, else: 2 1 iex> if true, [do: 1, else: 2] 1 iex> if(true, [do: 1, else: 2]) 1
  • 12. Homoiconicity In a homoiconic language the primary representa3on of programs is also a data structure in a primi3ve type of the language itself. This makes metaprogramming easier than in a language without this property, since code can be treated as data: reflec3on in the language (examining the program's en33es at run3me) depends on a single, homogeneous structure, and it does not have to handle several different structures that would appear in a complex syntax. To put that another way, homoiconicity is where a program's source code is wriDen as a basic data structure that the programming language knows how to access.
  • 13. quote iex> length [1,2,3] 3 iex> quote do: length [1,2,3] {:length, [context: Elixir, import: Kernel], [[1, 2, 3]]} iex> 1 + 2 3 iex> quote do: 1 + 2 {:+, [context: Elixir, import: Kernel], [1, 2]}
  • 14. macro iex> defmodule MyUnless do ...> defmacro unless(clause, options) do ...> quote do: if !unquote(clause), ...> unquote(options) ...> end ...> end iex> require MyUnless nil Iex> MyUnless.unless true, do: 1, else: 2 2
  • 15. defmacro if defmacro if(condition, clauses) do do_clause = Keyword.get(clauses, :do, nil) else_clause = Keyword.get(clauses, :else, nil) quote do case unquote(condition) do _ in [false, nil] -> unquote(else_clause) _ -> unquote(do_clause) end end end