SlideShare ist ein Scribd-Unternehmen logo
1 von 3
Downloaden Sie, um offline zu lesen
CHEAT-SHEET
Folding
#1
∢
/ 
π’‚πŸŽ ∢
/ 
π’‚πŸ ∢
/ 
π’‚πŸ ∢
/ 
π’‚πŸ‘
𝒇
/ 
π’‚πŸŽ 𝒇
/ 
π’‚πŸ 𝒇
/ 
π’‚πŸ 𝒇
/ 
π’‚πŸ‘ 𝒆
@philip_schwarz
slides by https://fpilluminated.com/
𝐝𝐚𝐭𝐚 𝑡𝒂𝒕 = 𝒁𝒆𝒓𝒐 | 𝑺𝒖𝒄𝒄 𝑡𝒂𝒕 𝐝𝐚𝐭𝐚 π‘³π’Šπ’”π’• Ξ± = π‘΅π’Šπ’ | π‘ͺ𝒐𝒏𝒔 Ξ± (π‘³π’Šπ’”π’• Ξ±)
𝑓 :: 𝑡𝒂𝒕 β†’ 𝛼
𝑓 𝒁𝒆𝒓𝒐 = 𝑐
𝑓 𝑺𝒖𝒄𝒄 𝑛 = β„Ž 𝑓 𝑛
π‘“π‘œπ‘™π‘‘π‘› ∷ 𝛼 β†’ 𝛼 β†’ 𝛼 β†’ 𝑡𝒂𝒕 β†’ 𝛼
π‘“π‘œπ‘™π‘‘π‘› β„Ž 𝑐 𝒁𝒆𝒓𝒐 = 𝑐
π‘“π‘œπ‘™π‘‘π‘› β„Ž 𝑐 𝑺𝒖𝒄𝒄 𝑛 = β„Ž π‘“π‘œπ‘™π‘‘π‘› β„Ž 𝑐 𝑛
π‘š + 𝑛 = π‘“π‘œπ‘™π‘‘π‘› 𝑺𝒖𝒄𝒄 π‘š 𝑛
π‘š Γ— 𝑛 = π‘“π‘œπ‘™π‘‘π‘› πœ†π‘₯. π‘₯ + π‘š 𝒁𝒆𝒓𝒐 𝑛
π‘š ↑ 𝑛 = π‘“π‘œπ‘™π‘‘π‘› πœ†π‘₯. π‘₯ Γ— π‘š 𝑺𝒖𝒄𝒄 𝒁𝒆𝒓𝒐 𝑛
+ ∷ 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕
π‘š + 𝒁𝒆𝒓𝒐 = π‘š
π‘š + 𝑺𝒖𝒄𝒄 𝑛 = 𝑺𝒖𝒄𝒄 π‘š + 𝑛
(Γ—) ∷ 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕
π‘š Γ— 𝒁𝒆𝒓𝒐 = 𝒁𝒆𝒓𝒐
π‘š Γ— 𝑺𝒖𝒄𝒄 𝑛 = π‘š Γ— 𝑛 + π‘š
(↑) ∷ 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕
π‘š ↑ 𝒁𝒆𝒓𝒐 = 𝑺𝒖𝒄𝒄 𝒁𝒆𝒓𝒐
π‘š ↑ 𝑺𝒖𝒄𝒄 𝑛 = π‘š ↑ 𝑛 Γ— π‘š
π‘“π‘œπ‘™π‘‘π‘Ÿ ∷ 𝛼 β†’ 𝛽 β†’ 𝛽 β†’ 𝛽 β†’ 𝛼 β†’ 𝛽
π‘“π‘œπ‘™π‘‘π‘Ÿ 𝑓 𝑏 π‘΅π’Šπ’ = 𝑏
π‘“π‘œπ‘™π‘‘π‘Ÿ 𝑓 𝑏 (π‘ͺ𝒐𝒏𝒔 π‘₯ π‘₯𝑠) = 𝑓 π‘₯ π‘“π‘œπ‘™π‘‘π‘Ÿ 𝑓 𝑏 π‘₯𝑠
𝑓 :: π‘³π’Šπ’”π’• 𝛼 β†’ 𝛽
𝑓 π‘΅π’Šπ’ = 𝑐
𝑓 π‘ͺ𝒐𝒏𝒔 π‘₯ π‘₯𝑠 = β„Ž π‘₯ (𝑓 π‘₯𝑠)
π‘ π‘’π‘š ∷ π‘³π’Šπ’”π’• 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕
π‘ π‘’π‘š π‘΅π’Šπ’ = 𝒁𝒆𝒓𝒐
π‘ π‘’π‘š π‘ͺ𝒐𝒏𝒔 π‘₯ π‘₯𝑠 = π‘₯ + (π‘ π‘’π‘š π‘₯𝑠)
π‘Žπ‘π‘π‘’π‘›π‘‘ ∷ π‘³π’Šπ’”π’• 𝛼 β†’ π‘³π’Šπ’”π’• 𝛼 β†’ π‘³π’Šπ’”π’• 𝛼
π‘Žπ‘π‘π‘’π‘›π‘‘ π‘΅π’Šπ’ 𝑦𝑠 = 𝑦𝑠
π‘Žπ‘π‘π‘’π‘›π‘‘ π‘ͺ𝒐𝒏𝒔 π‘₯ π‘₯𝑠 𝑦𝑠 = π‘ͺ𝒐𝒏𝒔 π‘₯ (π‘Žπ‘π‘π‘’π‘›π‘‘ π‘₯𝑠 𝑦𝑠)
π‘™π‘’π‘›π‘”π‘‘β„Ž ∷ π‘³π’Šπ’”π’• 𝛼 β†’ 𝑡𝒂𝒕
π‘™π‘’π‘›π‘”π‘‘β„Ž π‘΅π’Šπ’ = 𝒁𝒆𝒓𝒐
π‘™π‘’π‘›π‘”π‘‘β„Ž π‘ͺ𝒐𝒏𝒔 π‘₯ π‘₯𝑠 = 𝑺𝒖𝒄𝒄 𝒁𝒆𝒓𝒐 + (π‘™π‘’π‘›π‘”π‘‘β„Ž π‘₯𝑠)
π‘ π‘’π‘š π‘₯𝑠 = π‘“π‘œπ‘™π‘‘π‘Ÿ + 𝒁𝒆𝒓𝒐 π‘₯𝑠
π‘™π‘’π‘›π‘”π‘‘β„Ž π‘₯𝑠 = π‘“π‘œπ‘™π‘‘π‘Ÿ πœ†π‘₯. πœ†π‘›. 𝑛 + 𝑺𝒖𝒄𝒄 𝒁𝒆𝒓𝒐 𝒁𝒆𝒓𝒐 π‘₯𝑠
π‘Žπ‘π‘π‘’π‘›π‘‘ π‘₯𝑠 𝑦𝑠 = π‘“π‘œπ‘™π‘‘π‘Ÿ π‘ͺ𝒐𝒏𝒔 𝑦𝑠 π‘₯𝑠
Common pattern for many recursive functions over 𝑡𝒂𝒕 : Common pattern for many recursive functions over π‘³π’Šπ’”π’•:
𝑐 :: 𝛼
β„Ž :: 𝛼 β†’ 𝛼
𝑐 :: 𝛽
β„Ž :: 𝛼 β†’ 𝛽
Three examples of such functions: Three examples of such functions:
The common pattern can be captured in a function: The common pattern can be captured in a function:
The three sample functions implemented using π‘“π‘œπ‘™π‘‘π‘›: The three sample functions implemented using π‘“π‘œπ‘™π‘‘π‘Ÿ:
https://fpilluminated.com/
inspired
by

Weitere Γ€hnliche Inhalte

Γ„hnlich wie Folding Cheat Sheet #1 - first in a series

Folding Cheat Sheet #2 - second in a series
Folding Cheat Sheet #2 - second in a seriesFolding Cheat Sheet #2 - second in a series
Folding Cheat Sheet #2 - second in a seriesPhilip Schwarz
Β 
Folding Cheat Sheet #2 - second in a series
Folding Cheat Sheet #2 - second in a seriesFolding Cheat Sheet #2 - second in a series
Folding Cheat Sheet #2 - second in a seriesPhilip Schwarz
Β 
SUEC 高中 Adv Maths (Irrational Part 3)
SUEC 高中 Adv Maths (Irrational Part 3)SUEC 高中 Adv Maths (Irrational Part 3)
SUEC 高中 Adv Maths (Irrational Part 3)tungwc
Β 
Review of generative adversarial nets
Review of generative adversarial netsReview of generative adversarial nets
Review of generative adversarial netsSungminYou
Β 
07.mdsd_modelado_termicos_liquidos
07.mdsd_modelado_termicos_liquidos07.mdsd_modelado_termicos_liquidos
07.mdsd_modelado_termicos_liquidosHipΓ³lito Aguilar
Β 
On ranges and null spaces of a special type of operator named 𝝀 βˆ’ π’‹π’†π’„π’•π’Šπ’π’. – ...
On ranges and null spaces of a special type of operator named 𝝀 βˆ’ π’‹π’†π’„π’•π’Šπ’π’. – ...On ranges and null spaces of a special type of operator named 𝝀 βˆ’ π’‹π’†π’„π’•π’Šπ’π’. – ...
On ranges and null spaces of a special type of operator named 𝝀 βˆ’ π’‹π’†π’„π’•π’Šπ’π’. – ...IJMER
Β 
SUEC 高中 Adv Maths (Biquadratic Equation, Method of Changing the Variable, Rec...
SUEC 高中 Adv Maths (Biquadratic Equation, Method of Changing the Variable, Rec...SUEC 高中 Adv Maths (Biquadratic Equation, Method of Changing the Variable, Rec...
SUEC 高中 Adv Maths (Biquadratic Equation, Method of Changing the Variable, Rec...tungwc
Β 
SUEC 高中 Adv Maths (Quadratic Equation in One Variable)
SUEC 高中 Adv Maths (Quadratic Equation in One Variable)SUEC 高中 Adv Maths (Quadratic Equation in One Variable)
SUEC 高中 Adv Maths (Quadratic Equation in One Variable)tungwc
Β 
Carbohydrate Metabolism
Carbohydrate MetabolismCarbohydrate Metabolism
Carbohydrate MetabolismVedantPatel100
Β 
Blow up in a degenerate keller--segel system(Eng.)
Blow up in a degenerate keller--segel system(Eng.)Blow up in a degenerate keller--segel system(Eng.)
Blow up in a degenerate keller--segel system(Eng.)Takahiro Hashira
Β 
2018 Geometri Transformasi Perkalian 5 Isometri Kelompok 8 Rombel 3
2018 Geometri Transformasi Perkalian 5 Isometri Kelompok 8 Rombel 32018 Geometri Transformasi Perkalian 5 Isometri Kelompok 8 Rombel 3
2018 Geometri Transformasi Perkalian 5 Isometri Kelompok 8 Rombel 3Yosia Adi Setiawan
Β 
05.mdsd_modelado_mecanico_electrico
05.mdsd_modelado_mecanico_electrico05.mdsd_modelado_mecanico_electrico
05.mdsd_modelado_mecanico_electricoHipΓ³lito Aguilar
Β 
Teoria NumΓ©rica (Palestra 01)
Teoria NumΓ©rica (Palestra 01)Teoria NumΓ©rica (Palestra 01)
Teoria NumΓ©rica (Palestra 01)Eugenio Souza
Β 
Selection on Observables
Selection on ObservablesSelection on Observables
Selection on ObservablesMEASURE Evaluation
Β 

Γ„hnlich wie Folding Cheat Sheet #1 - first in a series (20)

Folding Cheat Sheet #2 - second in a series
Folding Cheat Sheet #2 - second in a seriesFolding Cheat Sheet #2 - second in a series
Folding Cheat Sheet #2 - second in a series
Β 
Folding Cheat Sheet #2 - second in a series
Folding Cheat Sheet #2 - second in a seriesFolding Cheat Sheet #2 - second in a series
Folding Cheat Sheet #2 - second in a series
Β 
Sets
SetsSets
Sets
Β 
Photosynthesis
PhotosynthesisPhotosynthesis
Photosynthesis
Β 
Instrumental Variables
Instrumental VariablesInstrumental Variables
Instrumental Variables
Β 
SUEC 高中 Adv Maths (Irrational Part 3)
SUEC 高中 Adv Maths (Irrational Part 3)SUEC 高中 Adv Maths (Irrational Part 3)
SUEC 高中 Adv Maths (Irrational Part 3)
Β 
Review of generative adversarial nets
Review of generative adversarial netsReview of generative adversarial nets
Review of generative adversarial nets
Β 
07.mdsd_modelado_termicos_liquidos
07.mdsd_modelado_termicos_liquidos07.mdsd_modelado_termicos_liquidos
07.mdsd_modelado_termicos_liquidos
Β 
On ranges and null spaces of a special type of operator named 𝝀 βˆ’ π’‹π’†π’„π’•π’Šπ’π’. – ...
On ranges and null spaces of a special type of operator named 𝝀 βˆ’ π’‹π’†π’„π’•π’Šπ’π’. – ...On ranges and null spaces of a special type of operator named 𝝀 βˆ’ π’‹π’†π’„π’•π’Šπ’π’. – ...
On ranges and null spaces of a special type of operator named 𝝀 βˆ’ π’‹π’†π’„π’•π’Šπ’π’. – ...
Β 
Enzymes
EnzymesEnzymes
Enzymes
Β 
SUEC 高中 Adv Maths (Biquadratic Equation, Method of Changing the Variable, Rec...
SUEC 高中 Adv Maths (Biquadratic Equation, Method of Changing the Variable, Rec...SUEC 高中 Adv Maths (Biquadratic Equation, Method of Changing the Variable, Rec...
SUEC 高中 Adv Maths (Biquadratic Equation, Method of Changing the Variable, Rec...
Β 
Ch 5 integration
Ch 5 integration  Ch 5 integration
Ch 5 integration
Β 
Integration
IntegrationIntegration
Integration
Β 
SUEC 高中 Adv Maths (Quadratic Equation in One Variable)
SUEC 高中 Adv Maths (Quadratic Equation in One Variable)SUEC 高中 Adv Maths (Quadratic Equation in One Variable)
SUEC 高中 Adv Maths (Quadratic Equation in One Variable)
Β 
Carbohydrate Metabolism
Carbohydrate MetabolismCarbohydrate Metabolism
Carbohydrate Metabolism
Β 
Blow up in a degenerate keller--segel system(Eng.)
Blow up in a degenerate keller--segel system(Eng.)Blow up in a degenerate keller--segel system(Eng.)
Blow up in a degenerate keller--segel system(Eng.)
Β 
2018 Geometri Transformasi Perkalian 5 Isometri Kelompok 8 Rombel 3
2018 Geometri Transformasi Perkalian 5 Isometri Kelompok 8 Rombel 32018 Geometri Transformasi Perkalian 5 Isometri Kelompok 8 Rombel 3
2018 Geometri Transformasi Perkalian 5 Isometri Kelompok 8 Rombel 3
Β 
05.mdsd_modelado_mecanico_electrico
05.mdsd_modelado_mecanico_electrico05.mdsd_modelado_mecanico_electrico
05.mdsd_modelado_mecanico_electrico
Β 
Teoria NumΓ©rica (Palestra 01)
Teoria NumΓ©rica (Palestra 01)Teoria NumΓ©rica (Palestra 01)
Teoria NumΓ©rica (Palestra 01)
Β 
Selection on Observables
Selection on ObservablesSelection on Observables
Selection on Observables
Β 

Mehr von Philip Schwarz

Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
Β 
Scala Left Fold Parallelisation - Three Approaches
Scala Left Fold Parallelisation- Three ApproachesScala Left Fold Parallelisation- Three Approaches
Scala Left Fold Parallelisation - Three ApproachesPhilip Schwarz
Β 
Tagless Final Encoding - Algebras and Interpreters and also Programs
Tagless Final Encoding - Algebras and Interpreters and also ProgramsTagless Final Encoding - Algebras and Interpreters and also Programs
Tagless Final Encoding - Algebras and Interpreters and also ProgramsPhilip Schwarz
Β 
Fusing Transformations of Strict Scala Collections with Views
Fusing Transformations of Strict Scala Collections with ViewsFusing Transformations of Strict Scala Collections with Views
Fusing Transformations of Strict Scala Collections with ViewsPhilip Schwarz
Β 
A sighting of traverse_ function in Practical FP in Scala
A sighting of traverse_ function in Practical FP in ScalaA sighting of traverse_ function in Practical FP in Scala
A sighting of traverse_ function in Practical FP in ScalaPhilip Schwarz
Β 
A sighting of traverseFilter and foldMap in Practical FP in Scala
A sighting of traverseFilter and foldMap in Practical FP in ScalaA sighting of traverseFilter and foldMap in Practical FP in Scala
A sighting of traverseFilter and foldMap in Practical FP in ScalaPhilip Schwarz
Β 
A sighting of sequence function in Practical FP in Scala
A sighting of sequence function in Practical FP in ScalaA sighting of sequence function in Practical FP in Scala
A sighting of sequence function in Practical FP in ScalaPhilip Schwarz
Β 
N-Queens Combinatorial Puzzle meets Cats
N-Queens Combinatorial Puzzle meets CatsN-Queens Combinatorial Puzzle meets Cats
N-Queens Combinatorial Puzzle meets CatsPhilip Schwarz
Β 
Kleisli composition, flatMap, join, map, unit - implementation and interrelat...
Kleisli composition, flatMap, join, map, unit - implementation and interrelat...Kleisli composition, flatMap, join, map, unit - implementation and interrelat...
Kleisli composition, flatMap, join, map, unit - implementation and interrelat...Philip Schwarz
Β 
The aggregate function - from sequential and parallel folds to parallel aggre...
The aggregate function - from sequential and parallel folds to parallel aggre...The aggregate function - from sequential and parallel folds to parallel aggre...
The aggregate function - from sequential and parallel folds to parallel aggre...Philip Schwarz
Β 
Nat, List and Option Monoids - from scratch - Combining and Folding - an example
Nat, List and Option Monoids -from scratch -Combining and Folding -an exampleNat, List and Option Monoids -from scratch -Combining and Folding -an example
Nat, List and Option Monoids - from scratch - Combining and Folding - an examplePhilip Schwarz
Β 
Nat, List and Option Monoids - from scratch - Combining and Folding - an example
Nat, List and Option Monoids -from scratch -Combining and Folding -an exampleNat, List and Option Monoids -from scratch -Combining and Folding -an example
Nat, List and Option Monoids - from scratch - Combining and Folding - an examplePhilip Schwarz
Β 
The Sieve of Eratosthenes - Part II - Genuine versus Unfaithful Sieve - Haske...
The Sieve of Eratosthenes - Part II - Genuine versus Unfaithful Sieve - Haske...The Sieve of Eratosthenes - Part II - Genuine versus Unfaithful Sieve - Haske...
The Sieve of Eratosthenes - Part II - Genuine versus Unfaithful Sieve - Haske...Philip Schwarz
Β 
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...Philip Schwarz
Β 
Algebraic Data Types for Data Oriented Programming - From Haskell and Scala t...
Algebraic Data Types forData Oriented Programming - From Haskell and Scala t...Algebraic Data Types forData Oriented Programming - From Haskell and Scala t...
Algebraic Data Types for Data Oriented Programming - From Haskell and Scala t...Philip Schwarz
Β 
Jordan Peterson - The pursuit of meaning and related ethical axioms
Jordan Peterson - The pursuit of meaning and related ethical axiomsJordan Peterson - The pursuit of meaning and related ethical axioms
Jordan Peterson - The pursuit of meaning and related ethical axiomsPhilip Schwarz
Β 
Defining filter using (a) recursion (b) folding (c) folding with S, B and I c...
Defining filter using (a) recursion (b) folding (c) folding with S, B and I c...Defining filter using (a) recursion (b) folding (c) folding with S, B and I c...
Defining filter using (a) recursion (b) folding (c) folding with S, B and I c...Philip Schwarz
Β 
Defining filter using (a) recursion (b) folding with S, B and I combinators (...
Defining filter using (a) recursion (b) folding with S, B and I combinators (...Defining filter using (a) recursion (b) folding with S, B and I combinators (...
Defining filter using (a) recursion (b) folding with S, B and I combinators (...Philip Schwarz
Β 
The Sieve of Eratosthenes - Part 1 - with minor corrections
The Sieve of Eratosthenes - Part 1 - with minor correctionsThe Sieve of Eratosthenes - Part 1 - with minor corrections
The Sieve of Eratosthenes - Part 1 - with minor correctionsPhilip Schwarz
Β 
The Sieve of Eratosthenes - Part 1
The Sieve of Eratosthenes - Part 1The Sieve of Eratosthenes - Part 1
The Sieve of Eratosthenes - Part 1Philip Schwarz
Β 

Mehr von Philip Schwarz (20)

Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
Β 
Scala Left Fold Parallelisation - Three Approaches
Scala Left Fold Parallelisation- Three ApproachesScala Left Fold Parallelisation- Three Approaches
Scala Left Fold Parallelisation - Three Approaches
Β 
Tagless Final Encoding - Algebras and Interpreters and also Programs
Tagless Final Encoding - Algebras and Interpreters and also ProgramsTagless Final Encoding - Algebras and Interpreters and also Programs
Tagless Final Encoding - Algebras and Interpreters and also Programs
Β 
Fusing Transformations of Strict Scala Collections with Views
Fusing Transformations of Strict Scala Collections with ViewsFusing Transformations of Strict Scala Collections with Views
Fusing Transformations of Strict Scala Collections with Views
Β 
A sighting of traverse_ function in Practical FP in Scala
A sighting of traverse_ function in Practical FP in ScalaA sighting of traverse_ function in Practical FP in Scala
A sighting of traverse_ function in Practical FP in Scala
Β 
A sighting of traverseFilter and foldMap in Practical FP in Scala
A sighting of traverseFilter and foldMap in Practical FP in ScalaA sighting of traverseFilter and foldMap in Practical FP in Scala
A sighting of traverseFilter and foldMap in Practical FP in Scala
Β 
A sighting of sequence function in Practical FP in Scala
A sighting of sequence function in Practical FP in ScalaA sighting of sequence function in Practical FP in Scala
A sighting of sequence function in Practical FP in Scala
Β 
N-Queens Combinatorial Puzzle meets Cats
N-Queens Combinatorial Puzzle meets CatsN-Queens Combinatorial Puzzle meets Cats
N-Queens Combinatorial Puzzle meets Cats
Β 
Kleisli composition, flatMap, join, map, unit - implementation and interrelat...
Kleisli composition, flatMap, join, map, unit - implementation and interrelat...Kleisli composition, flatMap, join, map, unit - implementation and interrelat...
Kleisli composition, flatMap, join, map, unit - implementation and interrelat...
Β 
The aggregate function - from sequential and parallel folds to parallel aggre...
The aggregate function - from sequential and parallel folds to parallel aggre...The aggregate function - from sequential and parallel folds to parallel aggre...
The aggregate function - from sequential and parallel folds to parallel aggre...
Β 
Nat, List and Option Monoids - from scratch - Combining and Folding - an example
Nat, List and Option Monoids -from scratch -Combining and Folding -an exampleNat, List and Option Monoids -from scratch -Combining and Folding -an example
Nat, List and Option Monoids - from scratch - Combining and Folding - an example
Β 
Nat, List and Option Monoids - from scratch - Combining and Folding - an example
Nat, List and Option Monoids -from scratch -Combining and Folding -an exampleNat, List and Option Monoids -from scratch -Combining and Folding -an example
Nat, List and Option Monoids - from scratch - Combining and Folding - an example
Β 
The Sieve of Eratosthenes - Part II - Genuine versus Unfaithful Sieve - Haske...
The Sieve of Eratosthenes - Part II - Genuine versus Unfaithful Sieve - Haske...The Sieve of Eratosthenes - Part II - Genuine versus Unfaithful Sieve - Haske...
The Sieve of Eratosthenes - Part II - Genuine versus Unfaithful Sieve - Haske...
Β 
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Β 
Algebraic Data Types for Data Oriented Programming - From Haskell and Scala t...
Algebraic Data Types forData Oriented Programming - From Haskell and Scala t...Algebraic Data Types forData Oriented Programming - From Haskell and Scala t...
Algebraic Data Types for Data Oriented Programming - From Haskell and Scala t...
Β 
Jordan Peterson - The pursuit of meaning and related ethical axioms
Jordan Peterson - The pursuit of meaning and related ethical axiomsJordan Peterson - The pursuit of meaning and related ethical axioms
Jordan Peterson - The pursuit of meaning and related ethical axioms
Β 
Defining filter using (a) recursion (b) folding (c) folding with S, B and I c...
Defining filter using (a) recursion (b) folding (c) folding with S, B and I c...Defining filter using (a) recursion (b) folding (c) folding with S, B and I c...
Defining filter using (a) recursion (b) folding (c) folding with S, B and I c...
Β 
Defining filter using (a) recursion (b) folding with S, B and I combinators (...
Defining filter using (a) recursion (b) folding with S, B and I combinators (...Defining filter using (a) recursion (b) folding with S, B and I combinators (...
Defining filter using (a) recursion (b) folding with S, B and I combinators (...
Β 
The Sieve of Eratosthenes - Part 1 - with minor corrections
The Sieve of Eratosthenes - Part 1 - with minor correctionsThe Sieve of Eratosthenes - Part 1 - with minor corrections
The Sieve of Eratosthenes - Part 1 - with minor corrections
Β 
The Sieve of Eratosthenes - Part 1
The Sieve of Eratosthenes - Part 1The Sieve of Eratosthenes - Part 1
The Sieve of Eratosthenes - Part 1
Β 

KΓΌrzlich hochgeladen

Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
Β 
Call Girls in Naraina Delhi πŸ’―Call Us πŸ”8264348440πŸ”
Call Girls in Naraina Delhi πŸ’―Call Us πŸ”8264348440πŸ”Call Girls in Naraina Delhi πŸ’―Call Us πŸ”8264348440πŸ”
Call Girls in Naraina Delhi πŸ’―Call Us πŸ”8264348440πŸ”soniya singh
Β 
εŠžη†ε­¦δ½θ―(UQ文凭证书)ζ˜†ε£«ε…°ε€§ε­¦ζ―•δΈšθ―ζˆη»©ε•εŽŸη‰ˆδΈ€ζ¨‘δΈ€ζ ·
εŠžη†ε­¦δ½θ―(UQ文凭证书)ζ˜†ε£«ε…°ε€§ε­¦ζ―•δΈšθ―ζˆη»©ε•εŽŸη‰ˆδΈ€ζ¨‘δΈ€ζ ·εŠžη†ε­¦δ½θ―(UQ文凭证书)ζ˜†ε£«ε…°ε€§ε­¦ζ―•δΈšθ―ζˆη»©ε•εŽŸη‰ˆδΈ€ζ¨‘δΈ€ζ ·
εŠžη†ε­¦δ½θ―(UQ文凭证书)ζ˜†ε£«ε…°ε€§ε­¦ζ―•δΈšθ―ζˆη»©ε•εŽŸη‰ˆδΈ€ζ¨‘δΈ€ζ ·umasea
Β 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
Β 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
Β 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
Β 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
Β 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
Β 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
Β 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
Β 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
Β 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
Β 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
Β 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
Β 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
Β 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
Β 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
Β 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
Β 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
Β 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
Β 

KΓΌrzlich hochgeladen (20)

Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Β 
Call Girls in Naraina Delhi πŸ’―Call Us πŸ”8264348440πŸ”
Call Girls in Naraina Delhi πŸ’―Call Us πŸ”8264348440πŸ”Call Girls in Naraina Delhi πŸ’―Call Us πŸ”8264348440πŸ”
Call Girls in Naraina Delhi πŸ’―Call Us πŸ”8264348440πŸ”
Β 
εŠžη†ε­¦δ½θ―(UQ文凭证书)ζ˜†ε£«ε…°ε€§ε­¦ζ―•δΈšθ―ζˆη»©ε•εŽŸη‰ˆδΈ€ζ¨‘δΈ€ζ ·
εŠžη†ε­¦δ½θ―(UQ文凭证书)ζ˜†ε£«ε…°ε€§ε­¦ζ―•δΈšθ―ζˆη»©ε•εŽŸη‰ˆδΈ€ζ¨‘δΈ€ζ ·εŠžη†ε­¦δ½θ―(UQ文凭证书)ζ˜†ε£«ε…°ε€§ε­¦ζ―•δΈšθ―ζˆη»©ε•εŽŸη‰ˆδΈ€ζ¨‘δΈ€ζ ·
εŠžη†ε­¦δ½θ―(UQ文凭证书)ζ˜†ε£«ε…°ε€§ε­¦ζ―•δΈšθ―ζˆη»©ε•εŽŸη‰ˆδΈ€ζ¨‘δΈ€ζ ·
Β 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Β 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
Β 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Β 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
Β 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
Β 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
Β 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
Β 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Β 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
Β 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
Β 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
Β 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Β 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
Β 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Β 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
Β 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
Β 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
Β 

Folding Cheat Sheet #1 - first in a series

  • 1. CHEAT-SHEET Folding #1 ∢ / π’‚πŸŽ ∢ / π’‚πŸ ∢ / π’‚πŸ ∢ / π’‚πŸ‘ 𝒇 / π’‚πŸŽ 𝒇 / π’‚πŸ 𝒇 / π’‚πŸ 𝒇 / π’‚πŸ‘ 𝒆 @philip_schwarz slides by https://fpilluminated.com/
  • 2. 𝐝𝐚𝐭𝐚 𝑡𝒂𝒕 = 𝒁𝒆𝒓𝒐 | 𝑺𝒖𝒄𝒄 𝑡𝒂𝒕 𝐝𝐚𝐭𝐚 π‘³π’Šπ’”π’• Ξ± = π‘΅π’Šπ’ | π‘ͺ𝒐𝒏𝒔 Ξ± (π‘³π’Šπ’”π’• Ξ±) 𝑓 :: 𝑡𝒂𝒕 β†’ 𝛼 𝑓 𝒁𝒆𝒓𝒐 = 𝑐 𝑓 𝑺𝒖𝒄𝒄 𝑛 = β„Ž 𝑓 𝑛 π‘“π‘œπ‘™π‘‘π‘› ∷ 𝛼 β†’ 𝛼 β†’ 𝛼 β†’ 𝑡𝒂𝒕 β†’ 𝛼 π‘“π‘œπ‘™π‘‘π‘› β„Ž 𝑐 𝒁𝒆𝒓𝒐 = 𝑐 π‘“π‘œπ‘™π‘‘π‘› β„Ž 𝑐 𝑺𝒖𝒄𝒄 𝑛 = β„Ž π‘“π‘œπ‘™π‘‘π‘› β„Ž 𝑐 𝑛 π‘š + 𝑛 = π‘“π‘œπ‘™π‘‘π‘› 𝑺𝒖𝒄𝒄 π‘š 𝑛 π‘š Γ— 𝑛 = π‘“π‘œπ‘™π‘‘π‘› πœ†π‘₯. π‘₯ + π‘š 𝒁𝒆𝒓𝒐 𝑛 π‘š ↑ 𝑛 = π‘“π‘œπ‘™π‘‘π‘› πœ†π‘₯. π‘₯ Γ— π‘š 𝑺𝒖𝒄𝒄 𝒁𝒆𝒓𝒐 𝑛 + ∷ 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕 π‘š + 𝒁𝒆𝒓𝒐 = π‘š π‘š + 𝑺𝒖𝒄𝒄 𝑛 = 𝑺𝒖𝒄𝒄 π‘š + 𝑛 (Γ—) ∷ 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕 π‘š Γ— 𝒁𝒆𝒓𝒐 = 𝒁𝒆𝒓𝒐 π‘š Γ— 𝑺𝒖𝒄𝒄 𝑛 = π‘š Γ— 𝑛 + π‘š (↑) ∷ 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕 π‘š ↑ 𝒁𝒆𝒓𝒐 = 𝑺𝒖𝒄𝒄 𝒁𝒆𝒓𝒐 π‘š ↑ 𝑺𝒖𝒄𝒄 𝑛 = π‘š ↑ 𝑛 Γ— π‘š π‘“π‘œπ‘™π‘‘π‘Ÿ ∷ 𝛼 β†’ 𝛽 β†’ 𝛽 β†’ 𝛽 β†’ 𝛼 β†’ 𝛽 π‘“π‘œπ‘™π‘‘π‘Ÿ 𝑓 𝑏 π‘΅π’Šπ’ = 𝑏 π‘“π‘œπ‘™π‘‘π‘Ÿ 𝑓 𝑏 (π‘ͺ𝒐𝒏𝒔 π‘₯ π‘₯𝑠) = 𝑓 π‘₯ π‘“π‘œπ‘™π‘‘π‘Ÿ 𝑓 𝑏 π‘₯𝑠 𝑓 :: π‘³π’Šπ’”π’• 𝛼 β†’ 𝛽 𝑓 π‘΅π’Šπ’ = 𝑐 𝑓 π‘ͺ𝒐𝒏𝒔 π‘₯ π‘₯𝑠 = β„Ž π‘₯ (𝑓 π‘₯𝑠) π‘ π‘’π‘š ∷ π‘³π’Šπ’”π’• 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕 π‘ π‘’π‘š π‘΅π’Šπ’ = 𝒁𝒆𝒓𝒐 π‘ π‘’π‘š π‘ͺ𝒐𝒏𝒔 π‘₯ π‘₯𝑠 = π‘₯ + (π‘ π‘’π‘š π‘₯𝑠) π‘Žπ‘π‘π‘’π‘›π‘‘ ∷ π‘³π’Šπ’”π’• 𝛼 β†’ π‘³π’Šπ’”π’• 𝛼 β†’ π‘³π’Šπ’”π’• 𝛼 π‘Žπ‘π‘π‘’π‘›π‘‘ π‘΅π’Šπ’ 𝑦𝑠 = 𝑦𝑠 π‘Žπ‘π‘π‘’π‘›π‘‘ π‘ͺ𝒐𝒏𝒔 π‘₯ π‘₯𝑠 𝑦𝑠 = π‘ͺ𝒐𝒏𝒔 π‘₯ (π‘Žπ‘π‘π‘’π‘›π‘‘ π‘₯𝑠 𝑦𝑠) π‘™π‘’π‘›π‘”π‘‘β„Ž ∷ π‘³π’Šπ’”π’• 𝛼 β†’ 𝑡𝒂𝒕 π‘™π‘’π‘›π‘”π‘‘β„Ž π‘΅π’Šπ’ = 𝒁𝒆𝒓𝒐 π‘™π‘’π‘›π‘”π‘‘β„Ž π‘ͺ𝒐𝒏𝒔 π‘₯ π‘₯𝑠 = 𝑺𝒖𝒄𝒄 𝒁𝒆𝒓𝒐 + (π‘™π‘’π‘›π‘”π‘‘β„Ž π‘₯𝑠) π‘ π‘’π‘š π‘₯𝑠 = π‘“π‘œπ‘™π‘‘π‘Ÿ + 𝒁𝒆𝒓𝒐 π‘₯𝑠 π‘™π‘’π‘›π‘”π‘‘β„Ž π‘₯𝑠 = π‘“π‘œπ‘™π‘‘π‘Ÿ πœ†π‘₯. πœ†π‘›. 𝑛 + 𝑺𝒖𝒄𝒄 𝒁𝒆𝒓𝒐 𝒁𝒆𝒓𝒐 π‘₯𝑠 π‘Žπ‘π‘π‘’π‘›π‘‘ π‘₯𝑠 𝑦𝑠 = π‘“π‘œπ‘™π‘‘π‘Ÿ π‘ͺ𝒐𝒏𝒔 𝑦𝑠 π‘₯𝑠 Common pattern for many recursive functions over 𝑡𝒂𝒕 : Common pattern for many recursive functions over π‘³π’Šπ’”π’•: 𝑐 :: 𝛼 β„Ž :: 𝛼 β†’ 𝛼 𝑐 :: 𝛽 β„Ž :: 𝛼 β†’ 𝛽 Three examples of such functions: Three examples of such functions: The common pattern can be captured in a function: The common pattern can be captured in a function: The three sample functions implemented using π‘“π‘œπ‘™π‘‘π‘›: The three sample functions implemented using π‘“π‘œπ‘™π‘‘π‘Ÿ: