SlideShare ist ein Scribd-Unternehmen logo
1 von 47
Downloaden Sie, um offline zu lesen
revival
Scala Summit 2016
•
Scala 

Scala ?
?
•Scala
•
•
Scala ?
•
•
•
•
•
•
•
•
f(x) = x + 1
Scala
• = ( )
•
Which
is
better?
def f(x: Int) {x + 1}
def f(x: Int) = x + 1
def f(x: Int) = return x + 1
※ : 2
( )
• (mutable)
•
•
2
?
int sum = 0;
for (int i = 0; i < array.length; i++) {
sum += array[i];
}
return sum;
i = i + 1;
?
https://goo.gl/iKyEKs
• 1 n
•
int f(int n) {
int total = 0;
for (int i = 1; i <= n; i++) {
total += i;
}
return total;
}
f(1) = 1
f(2) = 1 + 2
f(3) = 1 + 2 + 3
...
f(n) = 1 + 2 + 3 + ... + n
f(1) = 1
f(2) = f(1) + 2
f(3) = f(2) + 3
...
f(n) = f(n - 1) + n
f(1) = 1
f(n) = f(n - 1) + n
def f(n: Int): Int =
if (n == 1) 1
else f(n - 1) + n
f(1) = 1
f(n) = f(n - 1) + n
f(0) = 1
f(1) = 1
f(2) = 2 * 1
f(3) = 3 * 2 * 1
...
f(n) = n * ... * 3 * 2 * 1
f(0) = 1
f(1) = 1 * f(0)
f(2) = 2 * f(1)
f(3) = 3 * f(2)
...
f(n) = n * f(n - 1)
f(0) = 1
f(n) = n * f(n - 1)
def f(n: Int): Int =
if (n == 0) 1
else n * f(n - 1)
n
?
1, 1, 2, 3, 5, 8, 13, …
f(0) = 1
f(1) = 1
f(2) = 1 + 1
f(3) = 1 + 2
f(4) = 2 + 3
f(5) = 3 + 5
...
f(0) = 1
f(1) = 1
f(2) = f(0) + f(1)
f(3) = f(1) + f(2)
f(4) = f(2) + f(3)
f(5) = f(3) + f(4)
...
f(n) = f(n - 2) + f(n - 1)
f(0) = 1
f(1) = 1
f(n) = f(n - 2) + f(n - 1)
def f(n: Int): Int =
if (n == 0) 1
else if (n == 1) 1
else f(n - 2) + f(n - 1)
sum
def sum(ints: List[Int]): Int
• Nil
•head tail
head :: tail
3
Nil
Nil::
3 :: Nil2 ::
2 :: 3 :: Nil1 ::
•
•


5 :: 1 :: 2 :: 8 :: Nil
Nil
Nil::8
8 :: Nil::2
2 :: 8 :: Nil::1
1 :: 2 :: 8 :: Nil::5
sum(5 :: 1 :: 2 :: 8 :: Nil)
sum( ) = 0
sum( ) = 8 + 0
sum( ) = 2 + 8 + 0
sum( ) = 1 + 2 + 8 + 0
sum( ) = 5 + 1 + 2 + 8 + 0
Nil::8
Nil
8 :: Nil::2
2 :: 8 :: Nil::1
1 :: 2 :: 8 :: Nil::5
sum( ) = 0
sum( ) = + sum( )
sum( ) = + sum( )
sum( ) = + sum( )
sum( )

= + sum( )
Nil::8
Nil
8 :: Nil::2
2 :: 8 :: Nil::1
1 :: 2 :: 8 :: Nil::5
Nil8
8 :: Nil2
2 :: 8 :: Nil1
5 1 :: 2 :: 8 :: Nil
sum( ) = 0
sum( ) = + sum( )
sum( ) = + sum( )
sum( ) = + sum( )
Nil::8
Nil
8 :: Nil::2
2 :: 8 :: Nil::1
Nil8
8 :: Nil2
2 :: 8 :: Nil1
head tail
head tail
head tail
head tail head :: tail
sum(Nil) = 0
sum(head :: tail) = head + sum(tail)
def sum(list: List[Int]): Int =
if (list.isEmpty) 0
else list.head + sum(list.tail)
def sum(list: List[Int]): Int = list match {
case Nil => 0
case head :: tail => head + sum(tail)
}
def sum(list: List[Int]): Int = list match {
case Nil => 0
case head :: tail => head + sum(tail)
}
def sum(list: List[Int]): Int = {
def loop(acc: Int, l: List[Int]): Int = l match {
case Nil => acc
case head :: tail => loop(acc + head, tail)
}
loop(0, list)
}
product
def product(ints: List[Int]): Int
max
def max(ints: List[Int]): Int
reverse
def reverse(ints: List[Int]): List[Int]
length
def length(ints: List[Int]): Int
• Functional Programming Principles in Scala

Scala Martin Odersky


https://www.coursera.org/course/progfun
• 

OCaml


http://www.amazon.co.jp/dp/4781911609
• Scala & ―
Scalaz


2 

http://www.amazon.co.jp/dp/4844337769
Scala kansai summit-2016

Weitere ähnliche Inhalte

Was ist angesagt?

Part2 from math import * from simpson import * k=1 def f(x): return (exp(-(x...
Part2 from math import * from simpson import *  k=1 def f(x): return (exp(-(x...Part2 from math import * from simpson import *  k=1 def f(x): return (exp(-(x...
Part2 from math import * from simpson import * k=1 def f(x): return (exp(-(x...
hwbloom25
 
merged_document_3
merged_document_3merged_document_3
merged_document_3
tori hoff
 
ML: A Strongly Typed Functional Language
ML: A Strongly Typed Functional LanguageML: A Strongly Typed Functional Language
ML: A Strongly Typed Functional Language
lijx127
 
Answers sign-charts
Answers sign-chartsAnswers sign-charts
Answers sign-charts
math126
 
Palestra sobre Collections com Python
Palestra sobre Collections com PythonPalestra sobre Collections com Python
Palestra sobre Collections com Python
pugpe
 

Was ist angesagt? (20)

Part2 from math import * from simpson import * k=1 def f(x): return (exp(-(x...
Part2 from math import * from simpson import *  k=1 def f(x): return (exp(-(x...Part2 from math import * from simpson import *  k=1 def f(x): return (exp(-(x...
Part2 from math import * from simpson import * k=1 def f(x): return (exp(-(x...
 
All You Need is Fold
All You Need is FoldAll You Need is Fold
All You Need is Fold
 
The Ring programming language version 1.10 book - Part 33 of 212
The Ring programming language version 1.10 book - Part 33 of 212The Ring programming language version 1.10 book - Part 33 of 212
The Ring programming language version 1.10 book - Part 33 of 212
 
ES6(ES2015) is beautiful
ES6(ES2015) is beautifulES6(ES2015) is beautiful
ES6(ES2015) is beautiful
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
The Ring programming language version 1.8 book - Part 84 of 202
The Ring programming language version 1.8 book - Part 84 of 202The Ring programming language version 1.8 book - Part 84 of 202
The Ring programming language version 1.8 book - Part 84 of 202
 
Differntiation
 Differntiation Differntiation
Differntiation
 
Data made out of functions
Data made out of functionsData made out of functions
Data made out of functions
 
Utility Classes Are Killing Us
Utility Classes Are Killing UsUtility Classes Are Killing Us
Utility Classes Are Killing Us
 
Postfix Evaluations using Stack
Postfix Evaluations using StackPostfix Evaluations using Stack
Postfix Evaluations using Stack
 
À la découverte des Observables - HumanTalks Paris 2017
À la découverte des Observables - HumanTalks Paris 2017À la découverte des Observables - HumanTalks Paris 2017
À la découverte des Observables - HumanTalks Paris 2017
 
merged_document_3
merged_document_3merged_document_3
merged_document_3
 
ゲーム理論BASIC 第20回 -無限回繰り返しゲーム-
ゲーム理論BASIC 第20回 -無限回繰り返しゲーム-ゲーム理論BASIC 第20回 -無限回繰り返しゲーム-
ゲーム理論BASIC 第20回 -無限回繰り返しゲーム-
 
Oscilador de duffing forzado - coficación en fortran 90
Oscilador de duffing forzado - coficación en fortran 90Oscilador de duffing forzado - coficación en fortran 90
Oscilador de duffing forzado - coficación en fortran 90
 
ML: A Strongly Typed Functional Language
ML: A Strongly Typed Functional LanguageML: A Strongly Typed Functional Language
ML: A Strongly Typed Functional Language
 
Java interface and inheritance
Java interface and inheritanceJava interface and inheritance
Java interface and inheritance
 
All You Need is Fold in the Key of C#
All You Need is Fold in the Key of C#All You Need is Fold in the Key of C#
All You Need is Fold in the Key of C#
 
Answers sign-charts
Answers sign-chartsAnswers sign-charts
Answers sign-charts
 
Palestra sobre Collections com Python
Palestra sobre Collections com PythonPalestra sobre Collections com Python
Palestra sobre Collections com Python
 
Frsa
FrsaFrsa
Frsa
 

Andere mochten auch

Wingss power point
Wingss power pointWingss power point
Wingss power point
wingss
 
基隆交點Vol.5 - 王珈琳 - 陪伴,一段服務的時間
基隆交點Vol.5 - 王珈琳 - 陪伴,一段服務的時間基隆交點Vol.5 - 王珈琳 - 陪伴,一段服務的時間
基隆交點Vol.5 - 王珈琳 - 陪伴,一段服務的時間
交點
 
Nuevas tecnologías de
Nuevas tecnologías deNuevas tecnologías de
Nuevas tecnologías de
mariaelicena
 
Grafico diario del dax perfomance index para el 11 02-2013
Grafico diario del dax perfomance index para el 11 02-2013Grafico diario del dax perfomance index para el 11 02-2013
Grafico diario del dax perfomance index para el 11 02-2013
Experiencia Trading
 

Andere mochten auch (20)

インターンシップの学生にお届けしようとしたScalaの文法(初級編)
インターンシップの学生にお届けしようとしたScalaの文法(初級編)インターンシップの学生にお届けしようとしたScalaの文法(初級編)
インターンシップの学生にお届けしようとしたScalaの文法(初級編)
 
ガチのスタートアップがScalaを採用した結果(公開版) #scala_ks
ガチのスタートアップがScalaを採用した結果(公開版) #scala_ksガチのスタートアップがScalaを採用した結果(公開版) #scala_ks
ガチのスタートアップがScalaを採用した結果(公開版) #scala_ks
 
関数プログラミングことはじめ
関数プログラミングことはじめ関数プログラミングことはじめ
関数プログラミングことはじめ
 
オンプレミスから AWS への劇的ビフォーアフター
オンプレミスから AWS への劇的ビフォーアフターオンプレミスから AWS への劇的ビフォーアフター
オンプレミスから AWS への劇的ビフォーアフター
 
Scalaエンジニアのためのモナド入門
Scalaエンジニアのためのモナド入門Scalaエンジニアのためのモナド入門
Scalaエンジニアのためのモナド入門
 
Collaboration friday
Collaboration fridayCollaboration friday
Collaboration friday
 
Collaboration friday
Collaboration fridayCollaboration friday
Collaboration friday
 
Impacto de las tics en la educaciòn
Impacto de las tics en la educaciònImpacto de las tics en la educaciòn
Impacto de las tics en la educaciòn
 
1 4 vamos a jugar
1 4 vamos a jugar1 4 vamos a jugar
1 4 vamos a jugar
 
Wingss power point
Wingss power pointWingss power point
Wingss power point
 
부용
부용부용
부용
 
8th biosimilars congregation 2016
8th biosimilars congregation 20168th biosimilars congregation 2016
8th biosimilars congregation 2016
 
Historia insp manuel antonio leal chacon
Historia insp   manuel antonio leal chaconHistoria insp   manuel antonio leal chacon
Historia insp manuel antonio leal chacon
 
leonardo monsalve
leonardo monsalveleonardo monsalve
leonardo monsalve
 
基隆交點Vol.5 - 王珈琳 - 陪伴,一段服務的時間
基隆交點Vol.5 - 王珈琳 - 陪伴,一段服務的時間基隆交點Vol.5 - 王珈琳 - 陪伴,一段服務的時間
基隆交點Vol.5 - 王珈琳 - 陪伴,一段服務的時間
 
Nuevas tecnologías de
Nuevas tecnologías deNuevas tecnologías de
Nuevas tecnologías de
 
Grafico diario del dax perfomance index para el 11 02-2013
Grafico diario del dax perfomance index para el 11 02-2013Grafico diario del dax perfomance index para el 11 02-2013
Grafico diario del dax perfomance index para el 11 02-2013
 
Kerry Karl | Debunking Myths: GLUTEN
Kerry Karl | Debunking Myths: GLUTENKerry Karl | Debunking Myths: GLUTEN
Kerry Karl | Debunking Myths: GLUTEN
 
Brexit Webinar Series 3
Brexit Webinar Series 3Brexit Webinar Series 3
Brexit Webinar Series 3
 
Ratpack - SpringOne2GX 2015
Ratpack - SpringOne2GX 2015Ratpack - SpringOne2GX 2015
Ratpack - SpringOne2GX 2015
 

Ähnlich wie Scala kansai summit-2016

Scala - where objects and functions meet
Scala - where objects and functions meetScala - where objects and functions meet
Scala - where objects and functions meet
Mario Fusco
 
Matematika diskrit: fungsi pembangkit part 3
Matematika diskrit: fungsi pembangkit part 3Matematika diskrit: fungsi pembangkit part 3
Matematika diskrit: fungsi pembangkit part 3
radar radius
 
11 x1 t09 03 rules for differentiation (2013)
11 x1 t09 03 rules for differentiation (2013)11 x1 t09 03 rules for differentiation (2013)
11 x1 t09 03 rules for differentiation (2013)
Nigel Simmons
 
関数潮流(Function Tendency)
関数潮流(Function Tendency)関数潮流(Function Tendency)
関数潮流(Function Tendency)
riue
 

Ähnlich wie Scala kansai summit-2016 (20)

Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語
 
funwithalgorithms.pptx
funwithalgorithms.pptxfunwithalgorithms.pptx
funwithalgorithms.pptx
 
Prelude to halide_public
Prelude to halide_publicPrelude to halide_public
Prelude to halide_public
 
Elixir -Tolerância a Falhas para Adultos - GDG Campinas
Elixir  -Tolerância a Falhas para Adultos - GDG CampinasElixir  -Tolerância a Falhas para Adultos - GDG Campinas
Elixir -Tolerância a Falhas para Adultos - GDG Campinas
 
C Code and the Art of Obfuscation
C Code and the Art of ObfuscationC Code and the Art of Obfuscation
C Code and the Art of Obfuscation
 
Scala - where objects and functions meet
Scala - where objects and functions meetScala - where objects and functions meet
Scala - where objects and functions meet
 
Python 101 language features and functional programming
Python 101 language features and functional programmingPython 101 language features and functional programming
Python 101 language features and functional programming
 
Ch01 basic concepts_nosoluiton
Ch01 basic concepts_nosoluitonCh01 basic concepts_nosoluiton
Ch01 basic concepts_nosoluiton
 
Matematika diskrit: fungsi pembangkit part 3
Matematika diskrit: fungsi pembangkit part 3Matematika diskrit: fungsi pembangkit part 3
Matematika diskrit: fungsi pembangkit part 3
 
Go: It's Not Just For Google
Go: It's Not Just For GoogleGo: It's Not Just For Google
Go: It's Not Just For Google
 
Fp intro scala
Fp intro scalaFp intro scala
Fp intro scala
 
Capitulo 2 corripio
Capitulo 2 corripioCapitulo 2 corripio
Capitulo 2 corripio
 
corripio
corripio corripio
corripio
 
11 x1 t09 03 rules for differentiation (2013)
11 x1 t09 03 rules for differentiation (2013)11 x1 t09 03 rules for differentiation (2013)
11 x1 t09 03 rules for differentiation (2013)
 
関数潮流(Function Tendency)
関数潮流(Function Tendency)関数潮流(Function Tendency)
関数潮流(Function Tendency)
 
Grokking Monads in Scala
Grokking Monads in ScalaGrokking Monads in Scala
Grokking Monads in Scala
 
Ch5b.ppt
Ch5b.pptCh5b.ppt
Ch5b.ppt
 
Data Science for Folks Without (or With!) a Ph.D.
Data Science for Folks Without (or With!) a Ph.D.Data Science for Folks Without (or With!) a Ph.D.
Data Science for Folks Without (or With!) a Ph.D.
 
Scope Graphs: A fresh look at name binding in programming languages
Scope Graphs: A fresh look at name binding in programming languagesScope Graphs: A fresh look at name binding in programming languages
Scope Graphs: A fresh look at name binding in programming languages
 
chap 2 Ex#1.1
chap 2 Ex#1.1chap 2 Ex#1.1
chap 2 Ex#1.1
 

Kürzlich hochgeladen

Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 

Kürzlich hochgeladen (20)

WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 

Scala kansai summit-2016