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

Loïc Knuchel
Loïc KnuchelScala tech lead at Gospeak
Le retour de la fonction
@loicknuchel
Le retour de la fonction, HumanTalks le 11/10/2016
High-order function
Currying
Pure function
Functor
Monad
Monoid
Immutable
Récursif
Programmation générique
Le retour de la fonction, HumanTalks le 11/10/2016
Le retour de la fonction, HumanTalks le 11/10/2016
Le retour de la fonction, HumanTalks le 11/10/2016
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 !!!
Le retour de la fonction, HumanTalks le 11/10/2016
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]
Le retour de la fonction, HumanTalks le 11/10/2016
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
Le retour de la fonction, HumanTalks le 11/10/2016
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
1 of 30

Recommended

Manual penempatan murid secara manual sps by
Manual penempatan murid secara manual spsManual penempatan murid secara manual sps
Manual penempatan murid secara manual spscgdean_smkdbd
717 views16 slides
2014 스마트한 교실수업 by
2014 스마트한 교실수업2014 스마트한 교실수업
2014 스마트한 교실수업다혜 김
128 views4 slides
วัดคีรีวงศ์ by
วัดคีรีวงศ์ วัดคีรีวงศ์
วัดคีรีวงศ์ pisitpistarsat
135 views3 slides
Media evalution final versions by
Media evalution final versionsMedia evalution final versions
Media evalution final versionshaydnbarry
515 views33 slides
Presentation1 by
Presentation1Presentation1
Presentation1cathz1024
190 views5 slides
Equipo 6 sistemas operativos by
Equipo 6 sistemas operativosEquipo 6 sistemas operativos
Equipo 6 sistemas operativosAlfredo Hernandez
763 views13 slides

More Related Content

Viewers also liked

Socialgoal - Visionteractive by
Socialgoal - VisionteractiveSocialgoal - Visionteractive
Socialgoal - Visionteractiveecemmertturk
651 views10 slides
Hardware by
HardwareHardware
HardwareAlfredo Hernandez
175 views11 slides
TG2KM HHHC 9801 Kreatif dan Inovatif by
TG2KM HHHC 9801 Kreatif dan InovatifTG2KM HHHC 9801 Kreatif dan Inovatif
TG2KM HHHC 9801 Kreatif dan InovatifFatinNorAlia
243 views14 slides
communication channels or modes by
communication channels or modescommunication channels or modes
communication channels or modesGurpreet Singh
251 views21 slides
Bentley by
Bentley Bentley
Bentley Gurpreet Singh
177 views17 slides

More from Loïc Knuchel

Scala bad practices, scala.io 2019 by
Scala bad practices, scala.io 2019Scala bad practices, scala.io 2019
Scala bad practices, scala.io 2019Loïc Knuchel
803 views22 slides
Mutation testing, enfin une bonne mesure de la qualité des tests ?, RivieraDe... by
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...Loïc Knuchel
1.7K views43 slides
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016 by
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/2016Loïc Knuchel
962 views63 slides
Ionic2, les développeurs web à l'assaut du mobile, BDX I/O le 21/10/2016 by
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/2016Loïc Knuchel
504 views106 slides
Ionic2 - the raise of web developer, Riviera DEV le 17/06/2016 by
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/2016Loïc Knuchel
705 views71 slides
FP is coming... le 19/05/2016 by
FP is coming... le 19/05/2016FP is coming... le 19/05/2016
FP is coming... le 19/05/2016Loïc Knuchel
681 views98 slides

More from Loïc Knuchel(15)

Scala bad practices, scala.io 2019 by Loïc Knuchel
Scala bad practices, scala.io 2019Scala bad practices, scala.io 2019
Scala bad practices, scala.io 2019
Loïc Knuchel803 views
Mutation testing, enfin une bonne mesure de la qualité des tests ?, RivieraDe... by Loïc Knuchel
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...
Loïc Knuchel1.7K views
Comprendre la programmation fonctionnelle, Blend Web Mix le 02/11/2016 by Loïc Knuchel
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
Loïc Knuchel962 views
Ionic2, les développeurs web à l'assaut du mobile, BDX I/O le 21/10/2016 by Loïc Knuchel
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
Loïc Knuchel504 views
Ionic2 - the raise of web developer, Riviera DEV le 17/06/2016 by Loïc Knuchel
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
Loïc Knuchel705 views
FP is coming... le 19/05/2016 by Loïc Knuchel
FP is coming... le 19/05/2016FP is coming... le 19/05/2016
FP is coming... le 19/05/2016
Loïc Knuchel681 views
Programmation fonctionnelle en JavaScript by Loïc Knuchel
Programmation fonctionnelle en JavaScriptProgrammation fonctionnelle en JavaScript
Programmation fonctionnelle en JavaScript
Loïc Knuchel1.2K views
Ionic Framework, L'avenir du mobile sera hybride, bdx.io le 16-10-2015 by Loïc Knuchel
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
Loïc Knuchel2.8K views
Ionic, ce n'est pas que de l'UI, meetup PhoneGap le 25-05-2015 by Loïc Knuchel
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 Knuchel1.6K views
Le développement mobile hybride sort du bois, Ch'ti JUG le 15-04-2015 by Loïc Knuchel
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
Loïc Knuchel3.4K views
Devoxx 2015, Atelier Ionic - 09/04/2015 by Loïc Knuchel
Devoxx 2015, Atelier Ionic - 09/04/2015Devoxx 2015, Atelier Ionic - 09/04/2015
Devoxx 2015, Atelier Ionic - 09/04/2015
Loïc Knuchel3.4K views
Devoxx 2015, ionic chat by Loïc Knuchel
Devoxx 2015, ionic chatDevoxx 2015, ionic chat
Devoxx 2015, ionic chat
Loïc Knuchel2.5K views
Ionic HumanTalks - 11/03/2015 by Loïc Knuchel
Ionic HumanTalks - 11/03/2015Ionic HumanTalks - 11/03/2015
Ionic HumanTalks - 11/03/2015
Loïc Knuchel1.7K views
Ionic bbl le 19 février 2015 by Loïc Knuchel
Ionic bbl le 19 février 2015Ionic bbl le 19 février 2015
Ionic bbl le 19 février 2015
Loïc Knuchel5.7K views
Des maths et des recommandations - Devoxx 2014 by Loïc Knuchel
Des maths et des recommandations - Devoxx 2014Des maths et des recommandations - Devoxx 2014
Des maths et des recommandations - Devoxx 2014
Loïc Knuchel1.2K views

Recently uploaded

DSD-INT 2023 The Danube Hazardous Substances Model - Kovacs by
DSD-INT 2023 The Danube Hazardous Substances Model - KovacsDSD-INT 2023 The Danube Hazardous Substances Model - Kovacs
DSD-INT 2023 The Danube Hazardous Substances Model - KovacsDeltares
10 views17 slides
360 graden fabriek by
360 graden fabriek360 graden fabriek
360 graden fabriekinfo33492
122 views25 slides
Quality Engineer: A Day in the Life by
Quality Engineer: A Day in the LifeQuality Engineer: A Day in the Life
Quality Engineer: A Day in the LifeJohn Valentino
6 views18 slides
Airline Booking Software by
Airline Booking SoftwareAirline Booking Software
Airline Booking SoftwareSharmiMehta
6 views26 slides
AI and Ml presentation .pptx by
AI and Ml presentation .pptxAI and Ml presentation .pptx
AI and Ml presentation .pptxFayazAli87
12 views15 slides
FOSSLight Community Day 2023-11-30 by
FOSSLight Community Day 2023-11-30FOSSLight Community Day 2023-11-30
FOSSLight Community Day 2023-11-30Shane Coughlan
5 views18 slides

Recently uploaded(20)

DSD-INT 2023 The Danube Hazardous Substances Model - Kovacs by Deltares
DSD-INT 2023 The Danube Hazardous Substances Model - KovacsDSD-INT 2023 The Danube Hazardous Substances Model - Kovacs
DSD-INT 2023 The Danube Hazardous Substances Model - Kovacs
Deltares10 views
360 graden fabriek by info33492
360 graden fabriek360 graden fabriek
360 graden fabriek
info33492122 views
Quality Engineer: A Day in the Life by John Valentino
Quality Engineer: A Day in the LifeQuality Engineer: A Day in the Life
Quality Engineer: A Day in the Life
John Valentino6 views
Airline Booking Software by SharmiMehta
Airline Booking SoftwareAirline Booking Software
Airline Booking Software
SharmiMehta6 views
AI and Ml presentation .pptx by FayazAli87
AI and Ml presentation .pptxAI and Ml presentation .pptx
AI and Ml presentation .pptx
FayazAli8712 views
FOSSLight Community Day 2023-11-30 by Shane Coughlan
FOSSLight Community Day 2023-11-30FOSSLight Community Day 2023-11-30
FOSSLight Community Day 2023-11-30
Shane Coughlan5 views
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra... by Marc Müller
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra....NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
Marc Müller40 views
DSD-INT 2023 Process-based modelling of salt marsh development coupling Delft... by Deltares
DSD-INT 2023 Process-based modelling of salt marsh development coupling Delft...DSD-INT 2023 Process-based modelling of salt marsh development coupling Delft...
DSD-INT 2023 Process-based modelling of salt marsh development coupling Delft...
Deltares7 views
SUGCON ANZ Presentation V2.1 Final.pptx by Jack Spektor
SUGCON ANZ Presentation V2.1 Final.pptxSUGCON ANZ Presentation V2.1 Final.pptx
SUGCON ANZ Presentation V2.1 Final.pptx
Jack Spektor23 views
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports by Ra'Fat Al-Msie'deen
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug ReportsBushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports
Copilot Prompting Toolkit_All Resources.pdf by Riccardo Zamana
Copilot Prompting Toolkit_All Resources.pdfCopilot Prompting Toolkit_All Resources.pdf
Copilot Prompting Toolkit_All Resources.pdf
Riccardo Zamana10 views
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action by Márton Kodok
Gen Apps on Google Cloud PaLM2 and Codey APIs in ActionGen Apps on Google Cloud PaLM2 and Codey APIs in Action
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action
Márton Kodok6 views
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with... by sparkfabrik
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
sparkfabrik7 views
Dapr Unleashed: Accelerating Microservice Development by Miroslav Janeski
Dapr Unleashed: Accelerating Microservice DevelopmentDapr Unleashed: Accelerating Microservice Development
Dapr Unleashed: Accelerating Microservice Development
Miroslav Janeski10 views
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium... by Lisi Hocke
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Lisi Hocke35 views
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated... by TomHalpin9
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...
TomHalpin96 views

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

  • 1. Le retour de la fonction @loicknuchel
  • 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 !!!
  • 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]
  • 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
  • 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