SlideShare une entreprise Scribd logo
1  sur  49
By Luis Atencio (@luijar)
PHP = PHunctional Programming
Northeast
PHP
Conference 2016
What? Functional... PHP?
You don’t need to understand
Category Theory to grok FP
Agenda
1. Understand the FP stuff
2. Function composition and declarative coding
3. Currying
4. Functors
5. Monads
6. Cool FP libs for PHP
PHP functions became instances of
Closure
Mathematical-like computing
ƛx.x + 1
The birth of the anonymous function!
(ƛx.x + 1)3 = 4
(ƛx.x + 1)((ƛy.y + 2))3 = 6
What did we learn from the Maths?
Pure Functions
• No side effects!
• Clear contracts input and output
• Self-documenting
• Stateless
Immutability
• Can’t change the contents of something once it’s been initialized
Higher-order functions
• Pass functions into other functions
• Return functions from other functions
What is a side effect?
A function execution that impacts its outer scope. The effect is more
detrimental when it’s the global scope
Pure Functions
A function without side effects that returns the same result on
same input
Immutability
• Look at immutability through the consistent (repeatable) execution
of pure functions
• Most bugs originate from data issues
• Functions are (represent) immutable values
• Very limited support in PHP
Higher-order functions
• Pass functions to other functions
• Return functions from other functions
• Lazy evaluation
Variable functions
• If a variable has parenthesis appended to it, PHP will try to invoke
it
• Can be passed in by name (string) or reference
• Will not work with language constructs:
• echo
• print
• unset
• isset
• empty
Composition vs Inheritance
Composition vs Inheritance2
Adding new behavior
is easy
Functions are first-class in PHP
The Closure class was added in PHP 5.3.0
Everything is an object under the hood
Syntactic Sugar
Towards more functional code
PHP 4.0.6 introduced (but they are not pure!) to eliminate looping!
• array_map()
• array_filter()
• array_reduce()
Application State: OO
In OO you move state by passing objects around and invoking
methods on those objects. In FP you pass state to the functions and
combine them to move/transform it.
ObjectA
ObjectC
ObjectB
ObjectD
Application State: FP
In FP you pass state to the functions and combine them to
move/transform it.
FuncA
FuncC
FuncB
FuncD
FP vs OO
Declarative vs Imperative
Functions vs Objects
Stateless vs Stateful
Mutable vs Immutable
Declarative
• Describe WHAT a program does
• Not HOW to do it
Unix pipeline
SQL
Declarative2
Using PRamda Functional PHP Library
https://github.com/kapolos/pramda
Lambda Expressions
Arrow functions RFC under discussion
https://wiki.php.net/rfc/arrow_functions
Function composition
Declarative style + modularity
Function composition
The composition of functions f and g is another function that takes the
result of g and pass it to f:
f o g = f( g(x) )
f g Input: AOutput: C
A -> BB -> C
B
Function composition2
Examples:
This is where the term “Composer” comes from
Function composition3
It’s just the inverse of PIPE!
Point-free style!
Currying
• Composition requires we use single argument functions
• Partially evaluate a function as a sequence of steps providing one
argument at a time
• PHP uses eager function evaluation
function f(a, b) { … }
f a
evaluating: returns:
( )
Currying2
Transforms a multi-argument function into several single-arity functions
function f(a, b) { … }
curry(f) = function (a, b) {
return function (a) {
return function (b) {
...
}
}
}
wait to be invoked
Currying3
Example:
Currying + Composition
Example:
What about errors?
Map-able container
Containers are not new
Generalization
Protecting access to data
?
Mapping a value to a container
strtolower
HELLO
HELLO
Map function
hello
wrap
Container
HELLO Lift This is known as a Functor!!
Option Type
Intended for cases when you might want to return a value—like an
object, or (optionally) not—like null.
https://github.com/schmittjoh/php-option
vs
Option Type2
What to do with nested types?
Introducing flatMap()
This is known as a Monad!!
Reactive Programming
The Observable type
Treat any type of data (of any size) as a composable stream. Makes
use of the Observer pattern
More observables
Business
Logic
Orchestrate
Functional, Async computing
https://github.com/ReactiveX/RxPHP
Conclusion
PHP = FP + OO
“..FP in the small... OO in the large...”
- Michael Feathers
Resources
Functional PHP
Resource https://leanpub.com/functional-php
Free to read!!!
Functional Programming in JavaScript
Resource https://www.manning.com/atencio
Get on Amazon
RxJS in Action
Resource https://www.manning.com/books
/rxjs-in-action
Get on Manning.com
@luijar

Contenu connexe

Tendances

Function overloading(C++)
Function overloading(C++)Function overloading(C++)
Function overloading(C++)Ritika Sharma
 
Lambda Expressions in Java
Lambda Expressions in JavaLambda Expressions in Java
Lambda Expressions in JavaErhan Bagdemir
 
Java 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsJava 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsNewCircle Training
 
Definitions of Functional Programming
Definitions of Functional ProgrammingDefinitions of Functional Programming
Definitions of Functional ProgrammingPhilip Schwarz
 
Python Programming - III. Controlling the Flow
Python Programming - III. Controlling the FlowPython Programming - III. Controlling the Flow
Python Programming - III. Controlling the FlowRanel Padon
 
Keywords in python
Keywords in pythonKeywords in python
Keywords in pythonPushpakBhoge
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentationVan Huong
 
Functional Python Webinar from October 22nd, 2014
Functional Python Webinar from October 22nd, 2014Functional Python Webinar from October 22nd, 2014
Functional Python Webinar from October 22nd, 2014Reuven Lerner
 
Introduction To Programming with Python-1
Introduction To Programming with Python-1Introduction To Programming with Python-1
Introduction To Programming with Python-1Syed Farjad Zia Zaidi
 
JavaScript - Programming Languages course
JavaScript - Programming Languages course JavaScript - Programming Languages course
JavaScript - Programming Languages course yoavrubin
 
Functional Programming in Ruby
Functional Programming in RubyFunctional Programming in Ruby
Functional Programming in RubyAlex Teut
 
Differences between method overloading and method overriding
Differences between method overloading and method overridingDifferences between method overloading and method overriding
Differences between method overloading and method overridingPinky Anaya
 
Control structures functions and modules in python programming
Control structures functions and modules in python programmingControl structures functions and modules in python programming
Control structures functions and modules in python programmingSrinivas Narasegouda
 
Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2Syed Farjad Zia Zaidi
 

Tendances (20)

Function overloading(C++)
Function overloading(C++)Function overloading(C++)
Function overloading(C++)
 
Lambda Expressions in Java
Lambda Expressions in JavaLambda Expressions in Java
Lambda Expressions in Java
 
Java 8 by example!
Java 8 by example!Java 8 by example!
Java 8 by example!
 
Java 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsJava 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & Streams
 
Definitions of Functional Programming
Definitions of Functional ProgrammingDefinitions of Functional Programming
Definitions of Functional Programming
 
Functional go
Functional goFunctional go
Functional go
 
Python Programming - III. Controlling the Flow
Python Programming - III. Controlling the FlowPython Programming - III. Controlling the Flow
Python Programming - III. Controlling the Flow
 
Introduction to Python
Introduction to Python  Introduction to Python
Introduction to Python
 
Keywords in python
Keywords in pythonKeywords in python
Keywords in python
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
 
Functional Python Webinar from October 22nd, 2014
Functional Python Webinar from October 22nd, 2014Functional Python Webinar from October 22nd, 2014
Functional Python Webinar from October 22nd, 2014
 
Introduction To Programming with Python-1
Introduction To Programming with Python-1Introduction To Programming with Python-1
Introduction To Programming with Python-1
 
JavaScript - Programming Languages course
JavaScript - Programming Languages course JavaScript - Programming Languages course
JavaScript - Programming Languages course
 
Functional Programming in Ruby
Functional Programming in RubyFunctional Programming in Ruby
Functional Programming in Ruby
 
Differences between method overloading and method overriding
Differences between method overloading and method overridingDifferences between method overloading and method overriding
Differences between method overloading and method overriding
 
Functions in Python
Functions in PythonFunctions in Python
Functions in Python
 
Storage classess of C progamming
Storage classess of C progamming Storage classess of C progamming
Storage classess of C progamming
 
Control structures functions and modules in python programming
Control structures functions and modules in python programmingControl structures functions and modules in python programming
Control structures functions and modules in python programming
 
Python recursion
Python recursionPython recursion
Python recursion
 
Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2Introduction To Programming with Python Lecture 2
Introduction To Programming with Python Lecture 2
 

En vedette

Quick look in Reactive Extensions
Quick look in Reactive ExtensionsQuick look in Reactive Extensions
Quick look in Reactive Extensionsjohnlvidal
 
Resume alejandro garcia-de-frenza
Resume alejandro garcia-de-frenzaResume alejandro garcia-de-frenza
Resume alejandro garcia-de-frenzaAlejandro Garcia
 
open messenger-messaging-for-livelihood-development
open messenger-messaging-for-livelihood-developmentopen messenger-messaging-for-livelihood-development
open messenger-messaging-for-livelihood-developmentdigitalvisionoxfam
 
0 a045g formation-construction-de-typologie-et-modeles-d-association-avec-ibm...
0 a045g formation-construction-de-typologie-et-modeles-d-association-avec-ibm...0 a045g formation-construction-de-typologie-et-modeles-d-association-avec-ibm...
0 a045g formation-construction-de-typologie-et-modeles-d-association-avec-ibm...CERTyou Formation
 
Siklus estrus
Siklus estrusSiklus estrus
Siklus estrusInXs Bg
 
sf2-RecordOfAchievement
sf2-RecordOfAchievementsf2-RecordOfAchievement
sf2-RecordOfAchievementCharmi Jilka
 
1 introducao a quimica
1 introducao a quimica1 introducao a quimica
1 introducao a quimicaArilson Prata
 
Coservit - LeadSeed solution sheet
Coservit - LeadSeed solution sheetCoservit - LeadSeed solution sheet
Coservit - LeadSeed solution sheetMarketo
 
Siemens - SucessFactors Suite Overview
Siemens - SucessFactors Suite OverviewSiemens - SucessFactors Suite Overview
Siemens - SucessFactors Suite OverviewSyed Faisal Hasan
 
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...Nelson Calero
 
L'ere du Marketer Geek
L'ere du Marketer GeekL'ere du Marketer Geek
L'ere du Marketer GeekMarketo
 
Gestão de fluxo de caixa
Gestão de fluxo de caixaGestão de fluxo de caixa
Gestão de fluxo de caixaRoberto Toledo
 

En vedette (20)

Quick look in Reactive Extensions
Quick look in Reactive ExtensionsQuick look in Reactive Extensions
Quick look in Reactive Extensions
 
Presentation1
Presentation1Presentation1
Presentation1
 
Route Auchan Taverny
Route Auchan TavernyRoute Auchan Taverny
Route Auchan Taverny
 
K. Dharma Provissional Certi....
K. Dharma Provissional Certi....K. Dharma Provissional Certi....
K. Dharma Provissional Certi....
 
Reprogramación cronograma EUS semestre 2015 2
Reprogramación cronograma EUS semestre 2015 2Reprogramación cronograma EUS semestre 2015 2
Reprogramación cronograma EUS semestre 2015 2
 
Resume alejandro garcia-de-frenza
Resume alejandro garcia-de-frenzaResume alejandro garcia-de-frenza
Resume alejandro garcia-de-frenza
 
open messenger-messaging-for-livelihood-development
open messenger-messaging-for-livelihood-developmentopen messenger-messaging-for-livelihood-development
open messenger-messaging-for-livelihood-development
 
0 a045g formation-construction-de-typologie-et-modeles-d-association-avec-ibm...
0 a045g formation-construction-de-typologie-et-modeles-d-association-avec-ibm...0 a045g formation-construction-de-typologie-et-modeles-d-association-avec-ibm...
0 a045g formation-construction-de-typologie-et-modeles-d-association-avec-ibm...
 
Requisitos para Petición de Grado pregrado ucv
Requisitos para Petición de Grado   pregrado ucvRequisitos para Petición de Grado   pregrado ucv
Requisitos para Petición de Grado pregrado ucv
 
Siklus estrus
Siklus estrusSiklus estrus
Siklus estrus
 
sf2-RecordOfAchievement
sf2-RecordOfAchievementsf2-RecordOfAchievement
sf2-RecordOfAchievement
 
1 introducao a quimica
1 introducao a quimica1 introducao a quimica
1 introducao a quimica
 
Coservit - LeadSeed solution sheet
Coservit - LeadSeed solution sheetCoservit - LeadSeed solution sheet
Coservit - LeadSeed solution sheet
 
Siemens - SucessFactors Suite Overview
Siemens - SucessFactors Suite OverviewSiemens - SucessFactors Suite Overview
Siemens - SucessFactors Suite Overview
 
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
 
Certificados Locutor Acta 15
Certificados Locutor Acta 15Certificados Locutor Acta 15
Certificados Locutor Acta 15
 
Certificados Locutor Acta 14
Certificados Locutor Acta 14Certificados Locutor Acta 14
Certificados Locutor Acta 14
 
L'ere du Marketer Geek
L'ere du Marketer GeekL'ere du Marketer Geek
L'ere du Marketer Geek
 
Gestão de fluxo de caixa
Gestão de fluxo de caixaGestão de fluxo de caixa
Gestão de fluxo de caixa
 
Glosario
GlosarioGlosario
Glosario
 

Similaire à PHP = PHunctional Programming

Functional programming for the Advanced Beginner
Functional programming for the Advanced BeginnerFunctional programming for the Advanced Beginner
Functional programming for the Advanced BeginnerLuis Atencio
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answerskavinilavuG
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answersRojaPriya
 
Functional Programming In PHP I
Functional Programming In PHP IFunctional Programming In PHP I
Functional Programming In PHP IUmut IŞIK
 
Twins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional ProgrammingTwins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional ProgrammingRichardWarburton
 
Functions in Python Syntax and working .
Functions in Python Syntax and working .Functions in Python Syntax and working .
Functions in Python Syntax and working .tarunsharmaug23
 
Introduction to functional programming
Introduction to functional programmingIntroduction to functional programming
Introduction to functional programmingKonrad Szydlo
 
Exciting JavaScript - Part I
Exciting JavaScript - Part IExciting JavaScript - Part I
Exciting JavaScript - Part IEugene Lazutkin
 
Intro to functional programming
Intro to functional programmingIntro to functional programming
Intro to functional programmingAssaf Gannon
 
Python Interview Questions For Experienced
Python Interview Questions For ExperiencedPython Interview Questions For Experienced
Python Interview Questions For Experiencedzynofustechnology
 
OOP-Module-1-Section-4-LectureNo1-5.pptx
OOP-Module-1-Section-4-LectureNo1-5.pptxOOP-Module-1-Section-4-LectureNo1-5.pptx
OOP-Module-1-Section-4-LectureNo1-5.pptxsarthakgithub
 

Similaire à PHP = PHunctional Programming (20)

Functional programming for the Advanced Beginner
Functional programming for the Advanced BeginnerFunctional programming for the Advanced Beginner
Functional programming for the Advanced Beginner
 
Functional programming in python
Functional programming in pythonFunctional programming in python
Functional programming in python
 
Functional programming in python
Functional programming in pythonFunctional programming in python
Functional programming in python
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Functional Programming In PHP I
Functional Programming In PHP IFunctional Programming In PHP I
Functional Programming In PHP I
 
Twins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional ProgrammingTwins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional Programming
 
Functions in Python Syntax and working .
Functions in Python Syntax and working .Functions in Python Syntax and working .
Functions in Python Syntax and working .
 
Introduction to functional programming
Introduction to functional programmingIntroduction to functional programming
Introduction to functional programming
 
Exciting JavaScript - Part I
Exciting JavaScript - Part IExciting JavaScript - Part I
Exciting JavaScript - Part I
 
Basics of cpp
Basics of cppBasics of cpp
Basics of cpp
 
Python functions
Python functionsPython functions
Python functions
 
PHP7: Hello World!
PHP7: Hello World!PHP7: Hello World!
PHP7: Hello World!
 
Functions
FunctionsFunctions
Functions
 
Python and You Series
Python and You SeriesPython and You Series
Python and You Series
 
Php, mysq lpart3
Php, mysq lpart3Php, mysq lpart3
Php, mysq lpart3
 
Intro to functional programming
Intro to functional programmingIntro to functional programming
Intro to functional programming
 
Python Interview Questions For Experienced
Python Interview Questions For ExperiencedPython Interview Questions For Experienced
Python Interview Questions For Experienced
 
Python Session - 4
Python Session - 4Python Session - 4
Python Session - 4
 
OOP-Module-1-Section-4-LectureNo1-5.pptx
OOP-Module-1-Section-4-LectureNo1-5.pptxOOP-Module-1-Section-4-LectureNo1-5.pptx
OOP-Module-1-Section-4-LectureNo1-5.pptx
 

Plus de Luis Atencio

379008-rc217-functionalprogramming
379008-rc217-functionalprogramming379008-rc217-functionalprogramming
379008-rc217-functionalprogrammingLuis Atencio
 
Luis Atencio on RxJS
Luis Atencio on RxJSLuis Atencio on RxJS
Luis Atencio on RxJSLuis Atencio
 
Thinking Functionally with JavaScript
Thinking Functionally with JavaScriptThinking Functionally with JavaScript
Thinking Functionally with JavaScriptLuis Atencio
 
Functional Programming in JavaScript by Luis Atencio
Functional Programming in JavaScript by Luis AtencioFunctional Programming in JavaScript by Luis Atencio
Functional Programming in JavaScript by Luis AtencioLuis Atencio
 
Java script Techniques Part I
Java script Techniques Part IJava script Techniques Part I
Java script Techniques Part ILuis Atencio
 
Luis atencio on_git
Luis atencio on_gitLuis atencio on_git
Luis atencio on_gitLuis Atencio
 

Plus de Luis Atencio (7)

379008-rc217-functionalprogramming
379008-rc217-functionalprogramming379008-rc217-functionalprogramming
379008-rc217-functionalprogramming
 
DZone_RC_RxJS
DZone_RC_RxJSDZone_RC_RxJS
DZone_RC_RxJS
 
Luis Atencio on RxJS
Luis Atencio on RxJSLuis Atencio on RxJS
Luis Atencio on RxJS
 
Thinking Functionally with JavaScript
Thinking Functionally with JavaScriptThinking Functionally with JavaScript
Thinking Functionally with JavaScript
 
Functional Programming in JavaScript by Luis Atencio
Functional Programming in JavaScript by Luis AtencioFunctional Programming in JavaScript by Luis Atencio
Functional Programming in JavaScript by Luis Atencio
 
Java script Techniques Part I
Java script Techniques Part IJava script Techniques Part I
Java script Techniques Part I
 
Luis atencio on_git
Luis atencio on_gitLuis atencio on_git
Luis atencio on_git
 

Dernier

Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
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 Modelsaagamshah0812
 
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...panagenda
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
%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 tembisamasabamasaba
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
%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 masabamasaba
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
+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
 
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 AidPhilip Schwarz
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
%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 kaalfonteinmasabamasaba
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyAnusha Are
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 

Dernier (20)

Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
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
 
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...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
%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
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%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
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
+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...
 
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
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
%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
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 

PHP = PHunctional Programming

Notes de l'éditeur

  1. Didn’t we just become fully OO with 5.3? Functional Programming is the extensive use of functions to move the application from one state to the next
  2. Objective: Understand PHP bettter
  3. This gives rise to HO functions. Since objects can be passed around and returned
  4. Everything can be represented in the context of lambda expressions In school, we’re taught about Turing machines and Von Neumann Model
  5. Pure functions: count. Exceptions are thrown, printing to the console Is time() a pure function?
  6. Pure functions: count. Is time() a pure function?
  7. const cannot be used to conditionally define constants. To define a global constant, it has to be used in the outermost scope: if (...) { const FOO = 'BAR'; // invalid } // but if (...) { define('FOO', 'BAR'); // valid } const accepts a static scalar (number, string or other constant like true, false, null, __FILE__), whereas define() takes any expression. Since PHP 5.6 constant expressions are allowed in const as well: const BIT_5 = 1 << 5; // valid since PHP 5.6, invalid previously define('BIT_5', 1 << 5); // always valid const takes a plain constant name, whereas define() accepts any expression as name. This allows to do things like this: for ($i = 0; $i < 32; ++$i) { define('BIT_' . $i, 1 << $i); } consts are always case sensitive, whereas define() allows you to define case insensitive constants by passing true as the third argument const simply reads nicer. It's a language construct instead of a function and also is consistent with how you define constants in classes. const defines a constant in the current namespace, while define() has to be passed the full namespace name: namespace A\B\C; // To define the constant A\B\C\FOO: const FOO = 'BAR'; define('A\B\C\FOO', 'BAR'); Since PHP 5.6 const constants can also be arrays, while define() does not support arrays yet. However arrays will be supported for both cases in PHP 7. const FOO = [1, 2, 3]; // valid in PHP 5.6 define('FOO', [1, 2, 3]); // invalid in PHP 5.6, valid in PHP 7.0 As consts are language constructs and defined at compile time they are a bit faster than define()s.
  8. Adding a new strategy involves creating a new class. Ex. safeDivide
  9. FP makes patterns disappear
  10. No consistent API Cumbersome and verbose to use No currying Not immutable! They separate the loop away from your business logic
  11. This gives rise to HO functions. Since objects can be passed around and returned
  12. How to do it we let the compiler worry abo Variable functions ¶ PHP supports the concept of variable functions. This means that if a variable name has parentheses appended to it, PHP will look for a function with the same name as whatever the variable evaluates to, and will attempt to execute it. Among other things, this can be used to implement callbacks, function tables, and so forth. Variable functions won't work with language constructs such as echo, print, unset(), isset(), empty(), include,require and the like. Utilize wrapper functions to make use of any of these constructs as variable functions.
  13. How to do it we let the compiler worry abo Variable functions ¶ PHP supports the concept of variable functions. This means that if a variable name has parentheses appended to it, PHP will look for a function with the same name as whatever the variable evaluates to, and will attempt to execute it. Among other things, this can be used to implement callbacks, function tables, and so forth. Variable functions won't work with language constructs such as echo, print, unset(), isset(), empty(), include,require and the like. Utilize wrapper functions to make use of any of these constructs as variable functions.
  14. How to do it we let the compiler worry abo Variable functions ¶ PHP supports the concept of variable functions. This means that if a variable name has parentheses appended to it, PHP will look for a function with the same name as whatever the variable evaluates to, and will attempt to execute it. Among other things, this can be used to implement callbacks, function tables, and so forth. Variable functions won't work with language constructs such as echo, print, unset(), isset(), empty(), include,require and the like. Utilize wrapper functions to make use of any of these constructs as variable functions.
  15. This gives rise to HO functions. Since objects can be passed around and returned
  16. This is also known as point-free style
  17. We can do this thanks to HO functions
  18. This gives rise to HO functions. Since objects can be passed around and returned
  19. Most errors are due to error in the data
  20. This is a functor
  21. You are documenting the fact that you’re using this type Option is a monad!
  22. You are documenting the fact that you’re using this type Option is a monad!
  23. Didn’t we just become fully OO with 5.3?
  24. Didn’t we just become fully OO with 5.3? Functional Programming is the extensive use of functions to move the application from one state to the next