Suche senden
Hochladen
Hardcore functional programming
•
8 gefällt mir
•
2,063 views
Leonardo Andres Garcia Crespo
Folgen
Technologie
Melden
Teilen
Melden
Teilen
1 von 42
Jetzt herunterladen
Downloaden Sie, um offline zu lesen
Empfohlen
Day 1 examples u6w14
Day 1 examples u6w14
jchartiersjsd
Day 1 examples u8f13
Day 1 examples u8f13
jchartiersjsd
Lesson 3 Operation on Functions
Lesson 3 Operation on Functions
Shann Ashequielle Blasurca
Operation on functions
Operation on functions
Jeralyn Obsina
Operations With Functions May 25 2009
Operations With Functions May 25 2009
ingroy
Python 101 language features and functional programming
Python 101 language features and functional programming
Lukasz Dynowski
F(x) terminology
F(x) terminology
joannahstevens
Addition and Subtraction of Functions
Addition and Subtraction of Functions
jordhuffman
Empfohlen
Day 1 examples u6w14
Day 1 examples u6w14
jchartiersjsd
Day 1 examples u8f13
Day 1 examples u8f13
jchartiersjsd
Lesson 3 Operation on Functions
Lesson 3 Operation on Functions
Shann Ashequielle Blasurca
Operation on functions
Operation on functions
Jeralyn Obsina
Operations With Functions May 25 2009
Operations With Functions May 25 2009
ingroy
Python 101 language features and functional programming
Python 101 language features and functional programming
Lukasz Dynowski
F(x) terminology
F(x) terminology
joannahstevens
Addition and Subtraction of Functions
Addition and Subtraction of Functions
jordhuffman
Map reduce functional programming
Map reduce functional programming
tusjain
Composite functions
Composite functions
Shaun Wilson
Math - Operations on Functions, Kinds of Functions
Math - Operations on Functions, Kinds of Functions
Chuckie Balbuena
Alg2 lesson 7-7
Alg2 lesson 7-7
Carol Defreese
Alg2 lesson 7.7
Alg2 lesson 7.7
Carol Defreese
Company_X_Data_Analyst_Challenge
Company_X_Data_Analyst_Challenge
Mark Yashar
Mi primer map reduce
Mi primer map reduce
betabeers
Mi primer map reduce
Mi primer map reduce
Ruben Orta
Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...
Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...
Philip Schwarz
Laplace table
Laplace table
Thapar University
AP Calculus 1984 FRQs
AP Calculus 1984 FRQs
A Jorge Garcia
composite functions
composite functions
Glory Codilla
Data made out of functions
Data made out of functions
kenbot
Mathematical preliminaries in Automata
Mathematical preliminaries in Automata
Mobeen Mustafa
Composition Of Functions
Composition Of Functions
sjwong
MapReduce
MapReduce
hyun soomyung
2 1 Bzca5e
2 1 Bzca5e
silvia
Application of Derivative 5
Application of Derivative 5
Lakshmikanta Satapathy
Composite functions
Composite functions
Jessica Garcia
Running Free with the Monads
Running Free with the Monads
kenbot
Monads do not Compose
Monads do not Compose
Philip Schwarz
Fp in scala with adts
Fp in scala with adts
Hang Zhao
Weitere ähnliche Inhalte
Was ist angesagt?
Map reduce functional programming
Map reduce functional programming
tusjain
Composite functions
Composite functions
Shaun Wilson
Math - Operations on Functions, Kinds of Functions
Math - Operations on Functions, Kinds of Functions
Chuckie Balbuena
Alg2 lesson 7-7
Alg2 lesson 7-7
Carol Defreese
Alg2 lesson 7.7
Alg2 lesson 7.7
Carol Defreese
Company_X_Data_Analyst_Challenge
Company_X_Data_Analyst_Challenge
Mark Yashar
Mi primer map reduce
Mi primer map reduce
betabeers
Mi primer map reduce
Mi primer map reduce
Ruben Orta
Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...
Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...
Philip Schwarz
Laplace table
Laplace table
Thapar University
AP Calculus 1984 FRQs
AP Calculus 1984 FRQs
A Jorge Garcia
composite functions
composite functions
Glory Codilla
Data made out of functions
Data made out of functions
kenbot
Mathematical preliminaries in Automata
Mathematical preliminaries in Automata
Mobeen Mustafa
Composition Of Functions
Composition Of Functions
sjwong
MapReduce
MapReduce
hyun soomyung
2 1 Bzca5e
2 1 Bzca5e
silvia
Application of Derivative 5
Application of Derivative 5
Lakshmikanta Satapathy
Composite functions
Composite functions
Jessica Garcia
Running Free with the Monads
Running Free with the Monads
kenbot
Was ist angesagt?
(20)
Map reduce functional programming
Map reduce functional programming
Composite functions
Composite functions
Math - Operations on Functions, Kinds of Functions
Math - Operations on Functions, Kinds of Functions
Alg2 lesson 7-7
Alg2 lesson 7-7
Alg2 lesson 7.7
Alg2 lesson 7.7
Company_X_Data_Analyst_Challenge
Company_X_Data_Analyst_Challenge
Mi primer map reduce
Mi primer map reduce
Mi primer map reduce
Mi primer map reduce
Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...
Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...
Laplace table
Laplace table
AP Calculus 1984 FRQs
AP Calculus 1984 FRQs
composite functions
composite functions
Data made out of functions
Data made out of functions
Mathematical preliminaries in Automata
Mathematical preliminaries in Automata
Composition Of Functions
Composition Of Functions
MapReduce
MapReduce
2 1 Bzca5e
2 1 Bzca5e
Application of Derivative 5
Application of Derivative 5
Composite functions
Composite functions
Running Free with the Monads
Running Free with the Monads
Ähnlich wie Hardcore functional programming
Monads do not Compose
Monads do not Compose
Philip Schwarz
Fp in scala with adts
Fp in scala with adts
Hang Zhao
4 2 operations on functions
4 2 operations on functions
hisema01
1. functions
1. functions
Amirudin Mustapha
Introductory part of function for class 12th JEE
Introductory part of function for class 12th JEE
MohanSonawane
Functional Programming for OO Programmers (part 2)
Functional Programming for OO Programmers (part 2)
Calvin Cheng
FUNCTION EX 1 PROBLEMS WITH SOLUTION UPTO JEE LEVEL
FUNCTION EX 1 PROBLEMS WITH SOLUTION UPTO JEE LEVEL
MohanSonawane
Clojure to Slang
Clojure to Slang
Magne Gåsland
Monads from Definition
Monads from Definition
Dierk König
10.5 more on language of functions x
10.5 more on language of functions x
math260
5 algebra of functions
5 algebra of functions
Tzenma
Logarithms
Logarithms
supoteta
Basic Calculus.docx
Basic Calculus.docx
jericranoco
Functions and graphs
Functions and graphs
Sujata Tapare
Operations on Functions
Operations on Functions
swartzje
From Javascript To Haskell
From Javascript To Haskell
ujihisa
Fp in scala with adts part 2
Fp in scala with adts part 2
Hang Zhao
Functional Programming in PHP
Functional Programming in PHP
pwmosquito
Introduction to Monads in Scala (2)
Introduction to Monads in Scala (2)
stasimus
Operations on Functions.pdf
Operations on Functions.pdf
JetCarilloToledo
Ähnlich wie Hardcore functional programming
(20)
Monads do not Compose
Monads do not Compose
Fp in scala with adts
Fp in scala with adts
4 2 operations on functions
4 2 operations on functions
1. functions
1. functions
Introductory part of function for class 12th JEE
Introductory part of function for class 12th JEE
Functional Programming for OO Programmers (part 2)
Functional Programming for OO Programmers (part 2)
FUNCTION EX 1 PROBLEMS WITH SOLUTION UPTO JEE LEVEL
FUNCTION EX 1 PROBLEMS WITH SOLUTION UPTO JEE LEVEL
Clojure to Slang
Clojure to Slang
Monads from Definition
Monads from Definition
10.5 more on language of functions x
10.5 more on language of functions x
5 algebra of functions
5 algebra of functions
Logarithms
Logarithms
Basic Calculus.docx
Basic Calculus.docx
Functions and graphs
Functions and graphs
Operations on Functions
Operations on Functions
From Javascript To Haskell
From Javascript To Haskell
Fp in scala with adts part 2
Fp in scala with adts part 2
Functional Programming in PHP
Functional Programming in PHP
Introduction to Monads in Scala (2)
Introduction to Monads in Scala (2)
Operations on Functions.pdf
Operations on Functions.pdf
Kürzlich hochgeladen
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
gurkirankumar98700
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
Enterprise Knowledge
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
Anna Loughnan Colquhoun
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
soniya singh
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
BookNet Canada
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
Paola De la Torre
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
hans926745
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
Puma Security, LLC
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
Malak Abu Hammad
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
Scott Keck-Warren
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
Delhi Call girls
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Delhi Call girls
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Igalia
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
HampshireHUG
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
Pixlogix Infotech
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
Sinan KOZAK
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
🐬 The future of MySQL is Postgres 🐘
🐬 The future of MySQL is Postgres 🐘
RTylerCroy
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
ThousandEyes
Kürzlich hochgeladen
(20)
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
🐬 The future of MySQL is Postgres 🐘
🐬 The future of MySQL is Postgres 🐘
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
Hardcore functional programming
1.
Hardcore functional programming in Javascript Leonardo
Garcia Crespo @leogcrespo gh/leoasis
2.
Agenda ● Currying &
Partial Application ● Function Composition ● Fantasy Land ● Functors ● Monads
3.
Currying
4.
Currying: f(x, y, z)
= r f(x) -> g(y) -> h(z) => r
5.
function add(a) { return
function(b) { return a + b; }; } var add1 = add(1); add1(3); // 4
6.
function makeFullName(first) { return
function(middle) { return function(last) { return first + ' ' + middle + ' ' + last; }; }; } var makeJerry = makeFullName('Jerry'); makeJerry('Lee')('Lewis');
7.
var add1 =
add(1); add1(2); // 3 add(1)(2); // 3 add(1, 2); // ?
8.
_.curry(fn)
9.
var add =
_.curry(function(a, b) { return a + b; }); var add1 = add(1); add1(2); // 3 add(1)(2); // 3
10.
Partial Application
11.
var add1 =
add(1); var add1 = add.bind(null, 1); var add1 = _.partial(add, 1);
12.
Function Composition (f .
g)(x) = f(g(x)) _.compose(f, g)(x) == f(g(x))
13.
_.compose(reverse, toUpper)
14.
_.compose(reverse, toUpper) "Hello"
15.
_.compose(reverse, toUpper) "Hello"
16.
_.compose(reverse, toUpper) "HELLO"
17.
_.compose(reverse, toUpper) "HELLO"
18.
_.compose(reverse, toUpper) "HELLO"
19.
_.compose(reverse, toUpper) "OLLEH"
20.
_.compose(reverse, toUpper) "OLLEH"
21.
_.compose(reverse, toUpper) "OLLEH"
22.
Problem with _ Data
comes first: _.map(list, fn) _.reduce(list, fn) _.pluck(list, prop) ...
23.
If data came
last: var add1ToAll = _.map(add1); var names = _.map(get('name'));
24.
Examples
25.
Fantasy Land
26.
Functor Semigroup Monoid Apply Chain Applicative Monad
27.
Map for lists: map
:: (a -> b) -> [a] -> [b] map(add1, [1, 2, 3]) // [2, 3, 4]
28.
Functors map :: (a
-> b) -> F a -> F b where F is a functor
29.
Laws Identity: map(id, F a)
== F a map(id) == id Composition: map(f . g) == map(f) . map(g)
30.
Maybe Functor map(add1, Maybe(2));
// Maybe(3) map(add1, Maybe(null)); // Maybe(null)
31.
Promise Functor map(add1, Promise(2));
// Promise(3) map(add1, delay(3)); // Promise(...4)
32.
Examples
33.
Monads A functor that
also has: of :: a -> M a flatMap :: (a -> M b) -> M a -> M b or chain :: M a -> (a -> M b) -> M b
34.
Laws Left Identity: of(a).chain(f) ==
f(a) Right Identity: M(a).chain(of) == M(a) Associativity: M(a).chain(f).chain(g) == M(a).chain(x -> f(x).chain(g))
35.
List Monad Array.of(1); //
[1] var withNeg = function(a) { return [-a, a]; }; flatMap(withNeg, [1, 2, 3]); // [-1, 1, -2, 2, -3, 3] [1, 2, 3].chain(withNeg);
36.
Maybe Monad Maybe.of(1); //
Maybe(1) var getName = function(obj) { return Maybe(obj.name); }; flatMap(getName, Maybe({name: 'John'})) // Maybe('John') Maybe({name: 'John'}).chain(getName); flatMap(getName, Maybe({age: 20})); // Maybe(null)
37.
Promise Monad Promise.of(1); //
Promise(1) // findTodo :: Number -> Promise(todo) var findTodo = function(id) { return fetchFromDb('todo', id); }; flatMap(findTodo, Promise.of(123)); // Promise(...todo) Promise.of(123).chain(getName);
38.
Examples
39.
Next ● Monoids ● Applicative
Functors ● Learn a FP language! ● A LOT more than this
40.
Why? ● Declarative (what
vs how) ● Common Patterns ● Small functions ● Oriented to fns, not data ● Correctness (mathematics)
41.
Resources ● http://learnyouahaskell.com/ ● Hey
Underscore! You're Doing it wrong (https: //www.youtube.com/watch?v=m3svKOdZijA) ● https://github.com/fantasyland/fantasy-land ● http://functionaltalks.org ● Brian McKenna (@puffnfresh) & Brian Lonsdorf (@drboolean) on Twitter
42.
Thanks! Qs? Leonardo Garcia Crespo @leogcrespo gh/leoasis
Jetzt herunterladen