SlideShare a Scribd company logo
1 of 30
Download to read offline
Le retour de la fonction
@loicknuchel
High-order function
Currying
Pure function
Functor
Monad
Monoid
Immutable
Récursif
Programmation générique
for loop is everywhere
function toUpperCase(list){
var ret = [];
for(var i=0; i<list.length; i++){
ret[i] = list[i].toUpperCase();
}
return ret;
}
var names = ['Finn', 'Rey', 'Poe'];
console.log(toUpperCase(names));
// ['FINN', 'REY', 'POE']
for loop is everywhere
function toUpperCase(list){
var ret = [];
for(var i=0; i<list.length; i++){
ret[i] = list[i].toUpperCase();
}
return ret;
}
var names = ['Finn', 'Rey', 'Poe'];
console.log(toUpperCase(names));
// ['FINN', 'REY', 'POE']
Boilerplate !!!
Array.prototype.map = function(callback){
var array = this;
var result = [];
for(var i=0; i<array.length; i++){
result[i] = callback(array[i]);
}
return result;
};
for loop is everywhere
(High-order function)
for loop is everywhere
function toUpperCase(list){
return list.map(function(item){
return item.toUpperCase();
});
}
for loop is everywhere
function toUpperCase(list){
return list.map(item => item.toUpperCase());
}
Séparation technique vs métier
Array.prototype.map = function(callback){
var array = this;
var result = [];
for(var i=0; i<array.length; i++){
result[i] = callback(array[i]);
}
return result;
};
list.map(item => item.toUpperCase());
Générique / Réutilisable
Haut niveau d’abstraction
Concis / Expressif
Focalisé sur le domaine
Scala collection API (en partie)
def map[B](f: (A) => B): List[B]
def filter(p: (A) => Boolean): List[A]
def partition(p: (A) => Boolean): (List[A], List[A])
def zip[B](that: List[B]): List[(A, B)]
def sliding(size: Int): Iterator[List[A]]
def find(p: (A) => Boolean): Option[A]
def exists(p: (A) => Boolean): Boolean
def flatten[B]: List[B]
def flatMap[B](f: (A) => List[B]): List[B]
def groupBy[K](f: (A) => K): Map[K, List[A]]
def grouped(size: Int): Iterator[List[A]]
def fold[A1 >: A](z: A1)(op: (A1, A1) => A1): A1
def reduce[A1 >: A](op: (A1, A1) => A1): A1
def forall(p: (A) => Boolean): Boolean
def take(n: Int): List[A]
def drop(n: Int): List[A]
def distinct: List[A]
The billion dollar mistake !
function toUpperCase(list){
var ret = [];
for(var i=0; i<list.length; i++){
ret[i] = list[i].toUpperCase();
}
return ret;
}
Safe ?
The billion dollar mistake !
function toUpperCase(list){
var ret = [];
for(var i=0; i<list.length; i++){
ret[i] = list[i].toUpperCase();
}
return ret;
}
Unsafe !
Cannot read property 'xxx'
of undefined !!!
The billion dollar mistake !
function toUpperCase(list){
var ret = [];
for(var i=0; i<list.length; i++){
ret[i] = list[i].toUpperCase();
}
return ret;
}
function toUpperCase(list){
var ret = [];
if(Array.isArray(list)) {
for(var i=0; i<list.length; i++){
if(typeof list[i] === 'string'){
ret[i] = list[i].toUpperCase();
} else {
ret[i] = list[i];
}
}
}
return ret;
}
Unsafe ! Unreadable !
The billion dollar mistake !
function toUpperCase(list){
var ret = [];
for(var i=0; i<list.length; i++){
ret[i] = list[i].toUpperCase();
}
return ret;
}
function toUpperCase(list){
var ret = [];
if(Array.isArray(list)) {
for(var i=0; i<list.length; i++){
ret[i] = list[i].toUpperCase();
}
}
return ret;
}
function toUpperCase(list){
var ret = [];
if(Array.isArray(list)) {
for(var i=0; i<list.length; i++){
if(typeof list[i] === 'string'){
ret[i] = list[i].toUpperCase();
} else {
ret[i] = list[i];
}
}
}
return ret;
}
Unsafe ! Unreadable ! (not so) smart
The billion dollar mistake !
// no null !
def toUpperCase(list: List[String]) = list.map(_.toUpperCase)
def toUpperCase(list: List[Option[String]]) = list.map(_.map(_.toUpperCase))
List.map() vs Option.map() ???
List.map() vs Option.map() ???
Fonctors !!!
def toWords(sentences: List[String]): List[List[[String]] =
sentences.map(_.split(" ").toList)
def toWords(sentences: List[String]): List[String] =
sentences.flatMap(_.split(" ").toList)
def toWords(sentences: List[String]): List[List[[String]] =
sentences.map(_.split(" ").toList)
def toWords(sentences: List[String]): List[String] =
sentences.flatMap(_.split(" ").toList)
Applicative !
def toWords(sentences: List[String]): List[List[[String]] =
sentences.map(_.split(" ").toList)
def toWords(sentences: List[String]): List[String] =
sentences.flatMap(_.split(" ").toList)
Applicative !
Fonctor + Applicative = Monad
def toWords(sentences: List[String]): List[List[[String]] =
sentences.map(_.split(" ").toList)
def toWords(sentences: List[String]): List[String] =
sentences.flatMap(_.split(" ").toList)
Monads !
Option[A]
List[A]Future[A]
Page[A]
Take away
● Monter son niveau d’abstration (ASM -> IMP -> OOP -> FUN !)
● Bannir null !!!
● Remplacer les ‘for’ par des fonctions de plus haut niveau
● Séparer le code technique de la logique métier
Le retour de la fonction, HumanTalks le 11/10/2016
Le retour de la fonction, HumanTalks le 11/10/2016

More Related Content

Viewers also liked

Socialgoal - Visionteractive
Socialgoal - VisionteractiveSocialgoal - Visionteractive
Socialgoal - Visionteractive
ecemmertturk
 
TG2KM HHHC 9801 Kreatif dan Inovatif
TG2KM HHHC 9801 Kreatif dan InovatifTG2KM HHHC 9801 Kreatif dan Inovatif
TG2KM HHHC 9801 Kreatif dan Inovatif
FatinNorAlia
 
Rimagine Credentials_2016
Rimagine  Credentials_2016Rimagine  Credentials_2016
Rimagine Credentials_2016
Vicky Wei
 

Viewers also liked (12)

Socialgoal - Visionteractive
Socialgoal - VisionteractiveSocialgoal - Visionteractive
Socialgoal - Visionteractive
 
BreeCS Example Report - All Deliveries
BreeCS Example Report - All DeliveriesBreeCS Example Report - All Deliveries
BreeCS Example Report - All Deliveries
 
Hardware
HardwareHardware
Hardware
 
TG2KM HHHC 9801 Kreatif dan Inovatif
TG2KM HHHC 9801 Kreatif dan InovatifTG2KM HHHC 9801 Kreatif dan Inovatif
TG2KM HHHC 9801 Kreatif dan Inovatif
 
communication channels or modes
communication channels or modescommunication channels or modes
communication channels or modes
 
Bentley
Bentley Bentley
Bentley
 
Madhyapradesh foodprocessingindustry-150706102716-lva1-app6891
Madhyapradesh foodprocessingindustry-150706102716-lva1-app6891Madhyapradesh foodprocessingindustry-150706102716-lva1-app6891
Madhyapradesh foodprocessingindustry-150706102716-lva1-app6891
 
Rimagine Credentials_2016
Rimagine  Credentials_2016Rimagine  Credentials_2016
Rimagine Credentials_2016
 
Getting a DUI is a Financial Wrecking Ball
Getting a DUI is a Financial Wrecking BallGetting a DUI is a Financial Wrecking Ball
Getting a DUI is a Financial Wrecking Ball
 
Love
LoveLove
Love
 
6 Ways Your Brain Transforms Sound into Emotion
6 Ways Your Brain Transforms Sound into Emotion6 Ways Your Brain Transforms Sound into Emotion
6 Ways Your Brain Transforms Sound into Emotion
 
Costos predeterminados equipo 8
Costos predeterminados equipo 8Costos predeterminados equipo 8
Costos predeterminados equipo 8
 

More from Loïc Knuchel

Ionic, ce n'est pas que de l'UI, meetup PhoneGap le 25-05-2015
Ionic, ce n'est pas que de l'UI, meetup PhoneGap le 25-05-2015Ionic, ce n'est pas que de l'UI, meetup PhoneGap le 25-05-2015
Ionic, ce n'est pas que de l'UI, meetup PhoneGap le 25-05-2015
Loïc Knuchel
 
Devoxx 2015, ionic chat
Devoxx 2015, ionic chatDevoxx 2015, ionic chat
Devoxx 2015, ionic chat
Loïc Knuchel
 
Des maths et des recommandations - Devoxx 2014
Des maths et des recommandations - Devoxx 2014Des maths et des recommandations - Devoxx 2014
Des maths et des recommandations - Devoxx 2014
Loïc Knuchel
 

More from Loïc Knuchel (15)

Scala bad practices, scala.io 2019
Scala bad practices, scala.io 2019Scala bad practices, scala.io 2019
Scala bad practices, scala.io 2019
 
Mutation testing, enfin une bonne mesure de la qualité des tests ?, RivieraDe...
Mutation testing, enfin une bonne mesure de la qualité des tests ?, RivieraDe...Mutation testing, enfin une bonne mesure de la qualité des tests ?, RivieraDe...
Mutation testing, enfin une bonne mesure de la qualité des tests ?, RivieraDe...
 
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016
 
Ionic2, les développeurs web à l'assaut du mobile, BDX I/O le 21/10/2016
Ionic2, les développeurs web à l'assaut du mobile, BDX I/O le 21/10/2016Ionic2, les développeurs web à l'assaut du mobile, BDX I/O le 21/10/2016
Ionic2, les développeurs web à l'assaut du mobile, BDX I/O le 21/10/2016
 
Ionic2 - the raise of web developer, Riviera DEV le 17/06/2016
Ionic2 - the raise of web developer, Riviera DEV le 17/06/2016Ionic2 - the raise of web developer, Riviera DEV le 17/06/2016
Ionic2 - the raise of web developer, Riviera DEV le 17/06/2016
 
FP is coming... le 19/05/2016
FP is coming... le 19/05/2016FP is coming... le 19/05/2016
FP is coming... le 19/05/2016
 
Programmation fonctionnelle en JavaScript
Programmation fonctionnelle en JavaScriptProgrammation fonctionnelle en JavaScript
Programmation fonctionnelle en JavaScript
 
Ionic Framework, L'avenir du mobile sera hybride, bdx.io le 16-10-2015
Ionic Framework, L'avenir du mobile sera hybride, bdx.io le 16-10-2015Ionic Framework, L'avenir du mobile sera hybride, bdx.io le 16-10-2015
Ionic Framework, L'avenir du mobile sera hybride, bdx.io le 16-10-2015
 
Ionic, ce n'est pas que de l'UI, meetup PhoneGap le 25-05-2015
Ionic, ce n'est pas que de l'UI, meetup PhoneGap le 25-05-2015Ionic, ce n'est pas que de l'UI, meetup PhoneGap le 25-05-2015
Ionic, ce n'est pas que de l'UI, meetup PhoneGap le 25-05-2015
 
Le développement mobile hybride sort du bois, Ch'ti JUG le 15-04-2015
Le développement mobile hybride sort du bois, Ch'ti JUG le 15-04-2015Le développement mobile hybride sort du bois, Ch'ti JUG le 15-04-2015
Le développement mobile hybride sort du bois, Ch'ti JUG le 15-04-2015
 
Devoxx 2015, Atelier Ionic - 09/04/2015
Devoxx 2015, Atelier Ionic - 09/04/2015Devoxx 2015, Atelier Ionic - 09/04/2015
Devoxx 2015, Atelier Ionic - 09/04/2015
 
Devoxx 2015, ionic chat
Devoxx 2015, ionic chatDevoxx 2015, ionic chat
Devoxx 2015, ionic chat
 
Ionic HumanTalks - 11/03/2015
Ionic HumanTalks - 11/03/2015Ionic HumanTalks - 11/03/2015
Ionic HumanTalks - 11/03/2015
 
Ionic bbl le 19 février 2015
Ionic bbl le 19 février 2015Ionic bbl le 19 février 2015
Ionic bbl le 19 février 2015
 
Des maths et des recommandations - Devoxx 2014
Des maths et des recommandations - Devoxx 2014Des maths et des recommandations - Devoxx 2014
Des maths et des recommandations - Devoxx 2014
 

Recently uploaded

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 

Le retour de la fonction, HumanTalks le 11/10/2016

  • 1. Le retour de la fonction @loicknuchel
  • 2.
  • 4.
  • 5.
  • 6.
  • 7. for loop is everywhere function toUpperCase(list){ var ret = []; for(var i=0; i<list.length; i++){ ret[i] = list[i].toUpperCase(); } return ret; } var names = ['Finn', 'Rey', 'Poe']; console.log(toUpperCase(names)); // ['FINN', 'REY', 'POE']
  • 8. for loop is everywhere function toUpperCase(list){ var ret = []; for(var i=0; i<list.length; i++){ ret[i] = list[i].toUpperCase(); } return ret; } var names = ['Finn', 'Rey', 'Poe']; console.log(toUpperCase(names)); // ['FINN', 'REY', 'POE'] Boilerplate !!!
  • 9.
  • 10. Array.prototype.map = function(callback){ var array = this; var result = []; for(var i=0; i<array.length; i++){ result[i] = callback(array[i]); } return result; }; for loop is everywhere (High-order function)
  • 11. for loop is everywhere function toUpperCase(list){ return list.map(function(item){ return item.toUpperCase(); }); }
  • 12. for loop is everywhere function toUpperCase(list){ return list.map(item => item.toUpperCase()); }
  • 13. Séparation technique vs métier Array.prototype.map = function(callback){ var array = this; var result = []; for(var i=0; i<array.length; i++){ result[i] = callback(array[i]); } return result; }; list.map(item => item.toUpperCase()); Générique / Réutilisable Haut niveau d’abstraction Concis / Expressif Focalisé sur le domaine
  • 14. Scala collection API (en partie) def map[B](f: (A) => B): List[B] def filter(p: (A) => Boolean): List[A] def partition(p: (A) => Boolean): (List[A], List[A]) def zip[B](that: List[B]): List[(A, B)] def sliding(size: Int): Iterator[List[A]] def find(p: (A) => Boolean): Option[A] def exists(p: (A) => Boolean): Boolean def flatten[B]: List[B] def flatMap[B](f: (A) => List[B]): List[B] def groupBy[K](f: (A) => K): Map[K, List[A]] def grouped(size: Int): Iterator[List[A]] def fold[A1 >: A](z: A1)(op: (A1, A1) => A1): A1 def reduce[A1 >: A](op: (A1, A1) => A1): A1 def forall(p: (A) => Boolean): Boolean def take(n: Int): List[A] def drop(n: Int): List[A] def distinct: List[A]
  • 15.
  • 16. The billion dollar mistake ! function toUpperCase(list){ var ret = []; for(var i=0; i<list.length; i++){ ret[i] = list[i].toUpperCase(); } return ret; } Safe ?
  • 17. The billion dollar mistake ! function toUpperCase(list){ var ret = []; for(var i=0; i<list.length; i++){ ret[i] = list[i].toUpperCase(); } return ret; } Unsafe ! Cannot read property 'xxx' of undefined !!!
  • 18. The billion dollar mistake ! function toUpperCase(list){ var ret = []; for(var i=0; i<list.length; i++){ ret[i] = list[i].toUpperCase(); } return ret; } function toUpperCase(list){ var ret = []; if(Array.isArray(list)) { for(var i=0; i<list.length; i++){ if(typeof list[i] === 'string'){ ret[i] = list[i].toUpperCase(); } else { ret[i] = list[i]; } } } return ret; } Unsafe ! Unreadable !
  • 19. The billion dollar mistake ! function toUpperCase(list){ var ret = []; for(var i=0; i<list.length; i++){ ret[i] = list[i].toUpperCase(); } return ret; } function toUpperCase(list){ var ret = []; if(Array.isArray(list)) { for(var i=0; i<list.length; i++){ ret[i] = list[i].toUpperCase(); } } return ret; } function toUpperCase(list){ var ret = []; if(Array.isArray(list)) { for(var i=0; i<list.length; i++){ if(typeof list[i] === 'string'){ ret[i] = list[i].toUpperCase(); } else { ret[i] = list[i]; } } } return ret; } Unsafe ! Unreadable ! (not so) smart
  • 20.
  • 21. The billion dollar mistake ! // no null ! def toUpperCase(list: List[String]) = list.map(_.toUpperCase) def toUpperCase(list: List[Option[String]]) = list.map(_.map(_.toUpperCase))
  • 23. List.map() vs Option.map() ??? Fonctors !!!
  • 24. def toWords(sentences: List[String]): List[List[[String]] = sentences.map(_.split(" ").toList) def toWords(sentences: List[String]): List[String] = sentences.flatMap(_.split(" ").toList)
  • 25. def toWords(sentences: List[String]): List[List[[String]] = sentences.map(_.split(" ").toList) def toWords(sentences: List[String]): List[String] = sentences.flatMap(_.split(" ").toList) Applicative !
  • 26. def toWords(sentences: List[String]): List[List[[String]] = sentences.map(_.split(" ").toList) def toWords(sentences: List[String]): List[String] = sentences.flatMap(_.split(" ").toList) Applicative ! Fonctor + Applicative = Monad
  • 27. def toWords(sentences: List[String]): List[List[[String]] = sentences.map(_.split(" ").toList) def toWords(sentences: List[String]): List[String] = sentences.flatMap(_.split(" ").toList) Monads ! Option[A] List[A]Future[A] Page[A]
  • 28. Take away ● Monter son niveau d’abstration (ASM -> IMP -> OOP -> FUN !) ● Bannir null !!! ● Remplacer les ‘for’ par des fonctions de plus haut niveau ● Séparer le code technique de la logique métier