SlideShare une entreprise Scribd logo
1  sur  16
Télécharger pour lire hors ligne
1
Les concepts de la
programmation fonctionnelle
illustrés avec Java 8
by Yannick Chartois
@ychartois
2
Bodil Stokke
What Every Hipster Should Know About Functional
Programming
Vimeo / Parleys
Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8
3
Question
Maintenant que nous avons les lambdas, peut-on faire la
même chose avec Java 8?
Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8
4
First Class Function
Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8
Définition
“Les fonctions sont traitées par le langage comme des valeurs de
première classe.”
5
Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8
Code
Résultat
Function<String, String> hello = (String s) -> "hello " + s;
hello ;
// BaseConcepts$$Lambda$1@a09ee92
// != BaseConcepts@30f39991
hello.apply("Erouan") ;
// hello Erouan
6
Higher order function
Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8
Définition
“C'est une fonction qui prend une ou plusieurs fonctions comme
entrée et/ou qui renvoie une fonction”
7
Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8
Code
Résultat
List<String> filter( Predicate<String> f, List<String> values ) {
List<String> toReturn = new ArrayList<>();
for( String current : values ) {
if ( f.test(current) )
toReturn.add( current );
}
return toReturn; }
List<String> confs = Arrays.asList("jug", "devoxx", "javaone");
filter(s -> s.contains("j"), confs) ;
// [jug, javaone]
Filter
Java 8
confs.stream().filter( s -> s.contains("j") ).collect(Collectors.toList())
8
Functor
Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8
Définition
“C'est une collection d'éléments X qui peut s'appliquer une fonction
f: X -> Y pour créer une collection Y”
9
Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8
Code
Résultat
List<String> map( Function<String, String> f , List<String> values ) {
List<String> toReturn = new ArrayList<>();
for( String current : values ) {
toReturn.add( f.apply(current) );
}
return toReturn; }
List<String> confs = Arrays.asList( "jug", "devoxx", "javaone" );
map( s -> s.toUpperCase(), confs );
// [JUG, DEVOXX, JAVAONE]
Map
Java 8
confs.stream().map( s -> s.toUpperCase() ).collect( Collectors.toList() )
10
Reduction / Aggregation
Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8
Définition
Higher order function dont le but est de produire une valeur qui est
le résultat de l’application d’un opérateur sur tous les éléments
d’une structure de donnée
11
Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8
Code
Résultat
String reduce( BinaryOperator<String> op , List<String> values ) {
String toReturn = "";
for( String current : values ) {
toReturn = toReturn.isEmpty() ? current : op.apply(toReturn, current)
}
return toReturn; }
List<String> confs = Arrays.asList( "jug", "devoxx", "javaone" );
reduce( (s1, s2) -> s1 + ", " + S2, confs );
// jug, devoxx, javaone
Reduce / fold
Java 8
confs.stream().reduce((s1, s2) -> s1 + ", " + s2 ).get() )
12
Combinator
Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8
Définition
“C'est une fonction qui définie une nouvelle fonction à partir de ses
arguments ou d'autre combinators”
13
Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8
Problème
Solution
List< String > confs2 = Arrays.asList( "jug", "devoxx", "javaone", null );
map( s -> s.toUpperCase(), confs2);
// Exception in thread "main" java.lang.NullPointerException
Function< String, String > nullCheck( Function< String, String > f ) {
return (String s) -> s == null ? "null" : f.apply(s);
}
Null Combinator
Résultat
map( nullCheck(s -> s.toUpperCase()), confs2)
// [JUG, DEVOXX, JAVAONE, null]
14
Composition
Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8
Définition
“Combine plusieurs fonctions pour créer une nouvelle fonction”
15
Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8
Code
Résultat
Function<String, String> compose (
Function<String, String> f1, Function<String, String> f2 ){
return (String s) -> f1.apply( f2.apply(s) );
}
Function<String, String> up = (String s) -> s.toUpperCase();
Function<String, String> hello = (String s) -> "hello " + s;
up.apply( hello.apply("Erouan") );
compose( up, hello).apply("Erouan") ;
// HELLO EROUAN
Java 8
hello.andThen(up).apply("Erouan")
16
Twitter: @ychartois
Github: https://github.com/ychartois/ProgFoncJava8

Contenu connexe

Tendances

Introduction au langage Go
Introduction au langage GoIntroduction au langage Go
Introduction au langage GoSylvain Wallez
 
Asyncio: offrez des tulipes à vos entrées sorties asynchrones
Asyncio: offrez des tulipes à vos entrées sorties asynchronesAsyncio: offrez des tulipes à vos entrées sorties asynchrones
Asyncio: offrez des tulipes à vos entrées sorties asynchronestchappui
 
Présentation de Django @ Orange Labs (FR)
Présentation de Django @ Orange Labs (FR)Présentation de Django @ Orange Labs (FR)
Présentation de Django @ Orange Labs (FR)Martin Latrille
 
JDK 8, lambdas, streams, collectors - Bretagne Tour
JDK 8, lambdas, streams, collectors - Bretagne TourJDK 8, lambdas, streams, collectors - Bretagne Tour
JDK 8, lambdas, streams, collectors - Bretagne TourJosé Paumard
 
Java (8) eXperiments - DevoxxFR 2016
Java (8) eXperiments - DevoxxFR 2016Java (8) eXperiments - DevoxxFR 2016
Java (8) eXperiments - DevoxxFR 2016François Sarradin
 
Presentation du Livre Django Avancé
Presentation du Livre Django AvancéPresentation du Livre Django Avancé
Presentation du Livre Django AvancéYohannGabory
 
De Java à Kotlin - L'histoire d'une migration
De Java à Kotlin - L'histoire d'une migrationDe Java à Kotlin - L'histoire d'une migration
De Java à Kotlin - L'histoire d'une migrationRobin Penea
 
Techday Arrow Group: Java 8
Techday Arrow Group: Java 8Techday Arrow Group: Java 8
Techday Arrow Group: Java 8Arrow Group
 
Terraform OpenStack : Mise en pratique sur infrastructure OVH (Rennes devops)
Terraform OpenStack : Mise en pratique sur infrastructure OVH (Rennes devops) Terraform OpenStack : Mise en pratique sur infrastructure OVH (Rennes devops)
Terraform OpenStack : Mise en pratique sur infrastructure OVH (Rennes devops) Joël Séguillon
 
"Input/Ouput, 16 ans après" à Devoxx France 2012
"Input/Ouput, 16 ans après" à Devoxx France 2012"Input/Ouput, 16 ans après" à Devoxx France 2012
"Input/Ouput, 16 ans après" à Devoxx France 2012Jean-Michel Doudoux
 

Tendances (15)

Introduction au langage Go
Introduction au langage GoIntroduction au langage Go
Introduction au langage Go
 
Asyncio: offrez des tulipes à vos entrées sorties asynchrones
Asyncio: offrez des tulipes à vos entrées sorties asynchronesAsyncio: offrez des tulipes à vos entrées sorties asynchrones
Asyncio: offrez des tulipes à vos entrées sorties asynchrones
 
Présentation de Django @ Orange Labs (FR)
Présentation de Django @ Orange Labs (FR)Présentation de Django @ Orange Labs (FR)
Présentation de Django @ Orange Labs (FR)
 
JDK 8, lambdas, streams, collectors - Bretagne Tour
JDK 8, lambdas, streams, collectors - Bretagne TourJDK 8, lambdas, streams, collectors - Bretagne Tour
JDK 8, lambdas, streams, collectors - Bretagne Tour
 
JAVA 8
JAVA 8JAVA 8
JAVA 8
 
Paris js
Paris jsParis js
Paris js
 
Java (8) eXperiments - DevoxxFR 2016
Java (8) eXperiments - DevoxxFR 2016Java (8) eXperiments - DevoxxFR 2016
Java (8) eXperiments - DevoxxFR 2016
 
Hibernate jpa
Hibernate jpaHibernate jpa
Hibernate jpa
 
Presentation du Livre Django Avancé
Presentation du Livre Django AvancéPresentation du Livre Django Avancé
Presentation du Livre Django Avancé
 
De Java à Kotlin - L'histoire d'une migration
De Java à Kotlin - L'histoire d'une migrationDe Java à Kotlin - L'histoire d'une migration
De Java à Kotlin - L'histoire d'une migration
 
Jenkins
JenkinsJenkins
Jenkins
 
Django by mrjmad
Django by mrjmadDjango by mrjmad
Django by mrjmad
 
Techday Arrow Group: Java 8
Techday Arrow Group: Java 8Techday Arrow Group: Java 8
Techday Arrow Group: Java 8
 
Terraform OpenStack : Mise en pratique sur infrastructure OVH (Rennes devops)
Terraform OpenStack : Mise en pratique sur infrastructure OVH (Rennes devops) Terraform OpenStack : Mise en pratique sur infrastructure OVH (Rennes devops)
Terraform OpenStack : Mise en pratique sur infrastructure OVH (Rennes devops)
 
"Input/Ouput, 16 ans après" à Devoxx France 2012
"Input/Ouput, 16 ans après" à Devoxx France 2012"Input/Ouput, 16 ans après" à Devoxx France 2012
"Input/Ouput, 16 ans après" à Devoxx France 2012
 

En vedette

11 soalan sebelum beli theme wordpress
11 soalan sebelum beli theme wordpress11 soalan sebelum beli theme wordpress
11 soalan sebelum beli theme wordpressafri2
 
Concepts of functional programming
Concepts of functional programmingConcepts of functional programming
Concepts of functional programmingYannick Chartois
 
Owl rescue nov 2013
Owl rescue nov 2013Owl rescue nov 2013
Owl rescue nov 2013Kasumioda
 
Scopriariannabyskemalog babel
Scopriariannabyskemalog babelScopriariannabyskemalog babel
Scopriariannabyskemalog babelBabel
 
Babelinfograficamonamourisa2014
Babelinfograficamonamourisa2014Babelinfograficamonamourisa2014
Babelinfograficamonamourisa2014Babel
 
Les concepts de la programmation fonctionnelle illustrés avec Java 8
Les concepts de la programmation fonctionnelle illustrés avec Java 8Les concepts de la programmation fonctionnelle illustrés avec Java 8
Les concepts de la programmation fonctionnelle illustrés avec Java 8Yannick Chartois
 
Уютненько о Яндекс Директ
Уютненько о Яндекс ДиректУютненько о Яндекс Директ
Уютненько о Яндекс ДиректFelix315
 
Nova Marketing. Presentation.
Nova Marketing. Presentation.Nova Marketing. Presentation.
Nova Marketing. Presentation.Felix315
 

En vedette (13)

My profile
My profileMy profile
My profile
 
11 soalan sebelum beli theme wordpress
11 soalan sebelum beli theme wordpress11 soalan sebelum beli theme wordpress
11 soalan sebelum beli theme wordpress
 
Concepts of functional programming
Concepts of functional programmingConcepts of functional programming
Concepts of functional programming
 
Certifications Java
Certifications JavaCertifications Java
Certifications Java
 
Owl rescue nov 2013
Owl rescue nov 2013Owl rescue nov 2013
Owl rescue nov 2013
 
Gravity: A Love Story
Gravity: A Love StoryGravity: A Love Story
Gravity: A Love Story
 
Scopriariannabyskemalog babel
Scopriariannabyskemalog babelScopriariannabyskemalog babel
Scopriariannabyskemalog babel
 
Multi Recharge Company
Multi Recharge CompanyMulti Recharge Company
Multi Recharge Company
 
Babelinfograficamonamourisa2014
Babelinfograficamonamourisa2014Babelinfograficamonamourisa2014
Babelinfograficamonamourisa2014
 
Les concepts de la programmation fonctionnelle illustrés avec Java 8
Les concepts de la programmation fonctionnelle illustrés avec Java 8Les concepts de la programmation fonctionnelle illustrés avec Java 8
Les concepts de la programmation fonctionnelle illustrés avec Java 8
 
Уютненько о Яндекс Директ
Уютненько о Яндекс ДиректУютненько о Яндекс Директ
Уютненько о Яндекс Директ
 
Nova Marketing. Presentation.
Nova Marketing. Presentation.Nova Marketing. Presentation.
Nova Marketing. Presentation.
 
Domain Name System
Domain Name SystemDomain Name System
Domain Name System
 

Similaire à Les concepts de la programmation fonctionnelle illustrés avec java 8

Java 9 modulo les modules devoxx fr 2017
Java 9 modulo les modules devoxx fr 2017Java 9 modulo les modules devoxx fr 2017
Java 9 modulo les modules devoxx fr 2017Jean-Michel Doudoux
 
Introduction aux RIA (Rich Internet Applications)
Introduction aux RIA (Rich Internet Applications)Introduction aux RIA (Rich Internet Applications)
Introduction aux RIA (Rich Internet Applications)Tugdual Grall
 
react-slides.ppx (2) (1).pptx react presentation basic
react-slides.ppx (2) (1).pptx react presentation basicreact-slides.ppx (2) (1).pptx react presentation basic
react-slides.ppx (2) (1).pptx react presentation basiczineblahib2
 
Fork / Join, Parallel Arrays, Lambdas : la programmation parallèle (trop ?) f...
Fork / Join, Parallel Arrays, Lambdas : la programmation parallèle (trop ?) f...Fork / Join, Parallel Arrays, Lambdas : la programmation parallèle (trop ?) f...
Fork / Join, Parallel Arrays, Lambdas : la programmation parallèle (trop ?) f...Normandy JUG
 
Quelle place pour le framework Rails dans le développement d'application web
Quelle place pour le framework Rails dans le développement d'application webQuelle place pour le framework Rails dans le développement d'application web
Quelle place pour le framework Rails dans le développement d'application web5pidou
 
Présentation Groovy
Présentation GroovyPrésentation Groovy
Présentation Groovyguest6e3bed
 
Présentation Groovy
Présentation GroovyPrésentation Groovy
Présentation GroovyJS Bournival
 
Back to the future of java (from 8 to 11 and beyond)
Back to the future of java (from 8 to 11 and beyond)Back to the future of java (from 8 to 11 and beyond)
Back to the future of java (from 8 to 11 and beyond)Jérôme Tamborini
 
201303 - Java8
201303 - Java8201303 - Java8
201303 - Java8lyonjug
 
GWT : under the hood
GWT : under the hoodGWT : under the hood
GWT : under the hoodsvuillet
 
Annotations pour les Geeks
Annotations pour les GeeksAnnotations pour les Geeks
Annotations pour les Geeksjviet
 
Hands on lab Elasticsearch
Hands on lab ElasticsearchHands on lab Elasticsearch
Hands on lab ElasticsearchDavid Pilato
 
Introduction à Groovy - OpenSource eXchange 2008
Introduction à Groovy - OpenSource eXchange 2008Introduction à Groovy - OpenSource eXchange 2008
Introduction à Groovy - OpenSource eXchange 2008Guillaume Laforge
 
JUG Nantes - Telosys Tools - Avril 2014
JUG Nantes - Telosys Tools - Avril 2014 JUG Nantes - Telosys Tools - Avril 2014
JUG Nantes - Telosys Tools - Avril 2014 telosys
 
Telosys tools jug-nantes-2014-v1.2
Telosys tools jug-nantes-2014-v1.2Telosys tools jug-nantes-2014-v1.2
Telosys tools jug-nantes-2014-v1.2Laurent Guérin
 
Grails from scratch to prod - MixIT 2011
Grails from scratch to prod - MixIT 2011Grails from scratch to prod - MixIT 2011
Grails from scratch to prod - MixIT 2011Aurélien Maury
 
Réu technodejs
Réu technodejsRéu technodejs
Réu technodejsnaholyr
 

Similaire à Les concepts de la programmation fonctionnelle illustrés avec java 8 (20)

Java 9 modulo les modules devoxx fr 2017
Java 9 modulo les modules devoxx fr 2017Java 9 modulo les modules devoxx fr 2017
Java 9 modulo les modules devoxx fr 2017
 
Introduction aux RIA (Rich Internet Applications)
Introduction aux RIA (Rich Internet Applications)Introduction aux RIA (Rich Internet Applications)
Introduction aux RIA (Rich Internet Applications)
 
react-slides.ppx (2) (1).pptx react presentation basic
react-slides.ppx (2) (1).pptx react presentation basicreact-slides.ppx (2) (1).pptx react presentation basic
react-slides.ppx (2) (1).pptx react presentation basic
 
Fork / Join, Parallel Arrays, Lambdas : la programmation parallèle (trop ?) f...
Fork / Join, Parallel Arrays, Lambdas : la programmation parallèle (trop ?) f...Fork / Join, Parallel Arrays, Lambdas : la programmation parallèle (trop ?) f...
Fork / Join, Parallel Arrays, Lambdas : la programmation parallèle (trop ?) f...
 
Quelle place pour le framework Rails dans le développement d'application web
Quelle place pour le framework Rails dans le développement d'application webQuelle place pour le framework Rails dans le développement d'application web
Quelle place pour le framework Rails dans le développement d'application web
 
Présentation Groovy
Présentation GroovyPrésentation Groovy
Présentation Groovy
 
Présentation Groovy
Présentation GroovyPrésentation Groovy
Présentation Groovy
 
Back to the future of java (from 8 to 11 and beyond)
Back to the future of java (from 8 to 11 and beyond)Back to the future of java (from 8 to 11 and beyond)
Back to the future of java (from 8 to 11 and beyond)
 
Support cours j2_ee
Support cours j2_eeSupport cours j2_ee
Support cours j2_ee
 
201303 - Java8
201303 - Java8201303 - Java8
201303 - Java8
 
GWT : under the hood
GWT : under the hoodGWT : under the hood
GWT : under the hood
 
react-fr.pdf
react-fr.pdfreact-fr.pdf
react-fr.pdf
 
Annotations pour les Geeks
Annotations pour les GeeksAnnotations pour les Geeks
Annotations pour les Geeks
 
Hands on lab Elasticsearch
Hands on lab ElasticsearchHands on lab Elasticsearch
Hands on lab Elasticsearch
 
Introduction à Groovy - OpenSource eXchange 2008
Introduction à Groovy - OpenSource eXchange 2008Introduction à Groovy - OpenSource eXchange 2008
Introduction à Groovy - OpenSource eXchange 2008
 
JUG Nantes - Telosys Tools - Avril 2014
JUG Nantes - Telosys Tools - Avril 2014 JUG Nantes - Telosys Tools - Avril 2014
JUG Nantes - Telosys Tools - Avril 2014
 
Telosys tools jug-nantes-2014-v1.2
Telosys tools jug-nantes-2014-v1.2Telosys tools jug-nantes-2014-v1.2
Telosys tools jug-nantes-2014-v1.2
 
Grails from scratch to prod - MixIT 2011
Grails from scratch to prod - MixIT 2011Grails from scratch to prod - MixIT 2011
Grails from scratch to prod - MixIT 2011
 
Dynamic Languages
Dynamic LanguagesDynamic Languages
Dynamic Languages
 
Réu technodejs
Réu technodejsRéu technodejs
Réu technodejs
 

Les concepts de la programmation fonctionnelle illustrés avec java 8

  • 1. 1 Les concepts de la programmation fonctionnelle illustrés avec Java 8 by Yannick Chartois @ychartois
  • 2. 2 Bodil Stokke What Every Hipster Should Know About Functional Programming Vimeo / Parleys Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8
  • 3. 3 Question Maintenant que nous avons les lambdas, peut-on faire la même chose avec Java 8? Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8
  • 4. 4 First Class Function Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8 Définition “Les fonctions sont traitées par le langage comme des valeurs de première classe.”
  • 5. 5 Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8 Code Résultat Function<String, String> hello = (String s) -> "hello " + s; hello ; // BaseConcepts$$Lambda$1@a09ee92 // != BaseConcepts@30f39991 hello.apply("Erouan") ; // hello Erouan
  • 6. 6 Higher order function Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8 Définition “C'est une fonction qui prend une ou plusieurs fonctions comme entrée et/ou qui renvoie une fonction”
  • 7. 7 Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8 Code Résultat List<String> filter( Predicate<String> f, List<String> values ) { List<String> toReturn = new ArrayList<>(); for( String current : values ) { if ( f.test(current) ) toReturn.add( current ); } return toReturn; } List<String> confs = Arrays.asList("jug", "devoxx", "javaone"); filter(s -> s.contains("j"), confs) ; // [jug, javaone] Filter Java 8 confs.stream().filter( s -> s.contains("j") ).collect(Collectors.toList())
  • 8. 8 Functor Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8 Définition “C'est une collection d'éléments X qui peut s'appliquer une fonction f: X -> Y pour créer une collection Y”
  • 9. 9 Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8 Code Résultat List<String> map( Function<String, String> f , List<String> values ) { List<String> toReturn = new ArrayList<>(); for( String current : values ) { toReturn.add( f.apply(current) ); } return toReturn; } List<String> confs = Arrays.asList( "jug", "devoxx", "javaone" ); map( s -> s.toUpperCase(), confs ); // [JUG, DEVOXX, JAVAONE] Map Java 8 confs.stream().map( s -> s.toUpperCase() ).collect( Collectors.toList() )
  • 10. 10 Reduction / Aggregation Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8 Définition Higher order function dont le but est de produire une valeur qui est le résultat de l’application d’un opérateur sur tous les éléments d’une structure de donnée
  • 11. 11 Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8 Code Résultat String reduce( BinaryOperator<String> op , List<String> values ) { String toReturn = ""; for( String current : values ) { toReturn = toReturn.isEmpty() ? current : op.apply(toReturn, current) } return toReturn; } List<String> confs = Arrays.asList( "jug", "devoxx", "javaone" ); reduce( (s1, s2) -> s1 + ", " + S2, confs ); // jug, devoxx, javaone Reduce / fold Java 8 confs.stream().reduce((s1, s2) -> s1 + ", " + s2 ).get() )
  • 12. 12 Combinator Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8 Définition “C'est une fonction qui définie une nouvelle fonction à partir de ses arguments ou d'autre combinators”
  • 13. 13 Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8 Problème Solution List< String > confs2 = Arrays.asList( "jug", "devoxx", "javaone", null ); map( s -> s.toUpperCase(), confs2); // Exception in thread "main" java.lang.NullPointerException Function< String, String > nullCheck( Function< String, String > f ) { return (String s) -> s == null ? "null" : f.apply(s); } Null Combinator Résultat map( nullCheck(s -> s.toUpperCase()), confs2) // [JUG, DEVOXX, JAVAONE, null]
  • 14. 14 Composition Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8 Définition “Combine plusieurs fonctions pour créer une nouvelle fonction”
  • 15. 15 Twitter: @ychartois – Github: https://github.com/ychartois/ProgFoncJava8 Code Résultat Function<String, String> compose ( Function<String, String> f1, Function<String, String> f2 ){ return (String s) -> f1.apply( f2.apply(s) ); } Function<String, String> up = (String s) -> s.toUpperCase(); Function<String, String> hello = (String s) -> "hello " + s; up.apply( hello.apply("Erouan") ); compose( up, hello).apply("Erouan") ; // HELLO EROUAN Java 8 hello.andThen(up).apply("Erouan")