Soumettre la recherche
Mettre en ligne
Folding Cheat Sheet #1 - first in a series
•
0 j'aime
•
14 vues
Philip Schwarz
Suivre
Folding over recursively defined data structures for natural numbers and lists.
Lire moins
Lire la suite
Logiciels
Signaler
Partager
Signaler
Partager
1 sur 3
Télécharger maintenant
Télécharger pour lire hors ligne
Recommandé
Left and Right Folds- Comparison of a mathematical definition and a programm...
Left and Right Folds- Comparison of a mathematical definition and a programm...
Philip Schwarz
Relativity
Relativity
edgardoangeles1
Pembuktian sifat sifat logaritma
Pembuktian sifat sifat logaritma
Franxisca Kurniawati
Folding Cheat Sheet #3 - third in a series
Folding Cheat Sheet #3 - third in a series
Philip Schwarz
Module 7 the antiderivative
Module 7 the antiderivative
REYEMMANUELILUMBA
Module 7 the antiderivative
Module 7 the antiderivative
REYEMMANUELILUMBA
Signal Flow Graph Examples
Signal Flow Graph Examples
Engineering Funda
Ranjak Vaidic Ganit Preview (Marathi Research Book)
Ranjak Vaidic Ganit Preview (Marathi Research Book)
Vitthal Jadhav
Recommandé
Left and Right Folds- Comparison of a mathematical definition and a programm...
Left and Right Folds- Comparison of a mathematical definition and a programm...
Philip Schwarz
Relativity
Relativity
edgardoangeles1
Pembuktian sifat sifat logaritma
Pembuktian sifat sifat logaritma
Franxisca Kurniawati
Folding Cheat Sheet #3 - third in a series
Folding Cheat Sheet #3 - third in a series
Philip Schwarz
Module 7 the antiderivative
Module 7 the antiderivative
REYEMMANUELILUMBA
Module 7 the antiderivative
Module 7 the antiderivative
REYEMMANUELILUMBA
Signal Flow Graph Examples
Signal Flow Graph Examples
Engineering Funda
Ranjak Vaidic Ganit Preview (Marathi Research Book)
Ranjak Vaidic Ganit Preview (Marathi Research Book)
Vitthal Jadhav
Folding Cheat Sheet #2 - second in a series
Folding Cheat Sheet #2 - second in a series
Philip Schwarz
Folding Cheat Sheet #2 - second in a series
Folding Cheat Sheet #2 - second in a series
Philip Schwarz
Sets
Sets
Fightgood Allmyheart
Photosynthesis
Photosynthesis
VedantPatel100
Instrumental Variables
Instrumental Variables
MEASURE Evaluation
SUEC 高中 Adv Maths (Irrational Part 3)
SUEC 高中 Adv Maths (Irrational Part 3)
tungwc
Review of generative adversarial nets
Review of generative adversarial nets
SungminYou
07.mdsd_modelado_termicos_liquidos
07.mdsd_modelado_termicos_liquidos
Hipó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 𝝀 − 𝒋𝒆𝒄𝒕𝒊𝒐𝒏. – ...
IJMER
Enzymes
Enzymes
VedantPatel100
SUEC 高中 Adv Maths (Biquadratic Equation, Method of Changing the Variable, Rec...
SUEC 高中 Adv Maths (Biquadratic Equation, Method of Changing the Variable, Rec...
tungwc
Ch 5 integration
Ch 5 integration
samirlakhanistb
Integration
Integration
Amit Chaudhary
SUEC 高中 Adv Maths (Quadratic Equation in One Variable)
SUEC 高中 Adv Maths (Quadratic Equation in One Variable)
tungwc
Carbohydrate Metabolism
Carbohydrate Metabolism
VedantPatel100
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 3
Yosia Adi Setiawan
05.mdsd_modelado_mecanico_electrico
05.mdsd_modelado_mecanico_electrico
Hipólito Aguilar
Teoria Numérica (Palestra 01)
Teoria Numérica (Palestra 01)
Eugenio Souza
Selection on Observables
Selection on Observables
MEASURE Evaluation
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
Philip Schwarz
Scala Left Fold Parallelisation- Three Approaches
Scala Left Fold Parallelisation- Three Approaches
Philip Schwarz
Contenu connexe
Similaire à Folding Cheat Sheet #1 - first in a series
Folding Cheat Sheet #2 - second in a series
Folding Cheat Sheet #2 - second in a series
Philip Schwarz
Folding Cheat Sheet #2 - second in a series
Folding Cheat Sheet #2 - second in a series
Philip Schwarz
Sets
Sets
Fightgood Allmyheart
Photosynthesis
Photosynthesis
VedantPatel100
Instrumental Variables
Instrumental Variables
MEASURE Evaluation
SUEC 高中 Adv Maths (Irrational Part 3)
SUEC 高中 Adv Maths (Irrational Part 3)
tungwc
Review of generative adversarial nets
Review of generative adversarial nets
SungminYou
07.mdsd_modelado_termicos_liquidos
07.mdsd_modelado_termicos_liquidos
Hipó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 𝝀 − 𝒋𝒆𝒄𝒕𝒊𝒐𝒏. – ...
IJMER
Enzymes
Enzymes
VedantPatel100
SUEC 高中 Adv Maths (Biquadratic Equation, Method of Changing the Variable, Rec...
SUEC 高中 Adv Maths (Biquadratic Equation, Method of Changing the Variable, Rec...
tungwc
Ch 5 integration
Ch 5 integration
samirlakhanistb
Integration
Integration
Amit Chaudhary
SUEC 高中 Adv Maths (Quadratic Equation in One Variable)
SUEC 高中 Adv Maths (Quadratic Equation in One Variable)
tungwc
Carbohydrate Metabolism
Carbohydrate Metabolism
VedantPatel100
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 3
Yosia Adi Setiawan
05.mdsd_modelado_mecanico_electrico
05.mdsd_modelado_mecanico_electrico
Hipólito Aguilar
Teoria Numérica (Palestra 01)
Teoria Numérica (Palestra 01)
Eugenio Souza
Selection on Observables
Selection on Observables
MEASURE Evaluation
Similaire à Folding Cheat Sheet #1 - first in a series
(20)
Folding 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 series
Sets
Sets
Photosynthesis
Photosynthesis
Instrumental Variables
Instrumental Variables
SUEC 高中 Adv Maths (Irrational Part 3)
SUEC 高中 Adv Maths (Irrational Part 3)
Review of generative adversarial nets
Review of generative adversarial nets
07.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 𝝀 − 𝒋𝒆𝒄𝒕𝒊𝒐𝒏. – ...
Enzymes
Enzymes
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
Integration
Integration
SUEC 高中 Adv Maths (Quadratic Equation in One Variable)
SUEC 高中 Adv Maths (Quadratic Equation in One Variable)
Carbohydrate Metabolism
Carbohydrate Metabolism
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 3
05.mdsd_modelado_mecanico_electrico
05.mdsd_modelado_mecanico_electrico
Teoria Numérica (Palestra 01)
Teoria Numérica (Palestra 01)
Selection on Observables
Selection on Observables
Plus de Philip Schwarz
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
Philip Schwarz
Scala Left Fold Parallelisation- Three Approaches
Scala Left Fold Parallelisation- Three Approaches
Philip Schwarz
Tagless Final Encoding - Algebras and Interpreters and also Programs
Tagless Final Encoding - Algebras and Interpreters and also Programs
Philip Schwarz
Fusing Transformations of Strict Scala Collections with Views
Fusing Transformations of Strict Scala Collections with Views
Philip Schwarz
A sighting of traverse_ function in Practical FP in Scala
A sighting of traverse_ function in Practical FP in Scala
Philip Schwarz
A sighting of traverseFilter and foldMap in Practical FP in Scala
A sighting of traverseFilter and foldMap in Practical FP in Scala
Philip Schwarz
A sighting of sequence function in Practical FP in Scala
A sighting of sequence function in Practical FP in Scala
Philip Schwarz
N-Queens Combinatorial Puzzle meets Cats
N-Queens Combinatorial Puzzle meets Cats
Philip Schwarz
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...
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 example
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 example
Philip Schwarz
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...
Philip Schwarz
Algebraic Data Types forData Oriented Programming - From Haskell and Scala t...
Algebraic Data Types forData 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 axioms
Philip 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...
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 (...
Philip Schwarz
The Sieve of Eratosthenes - Part 1 - with minor corrections
The Sieve of Eratosthenes - Part 1 - with minor corrections
Philip Schwarz
The Sieve of Eratosthenes - Part 1
The Sieve of Eratosthenes - Part 1
Philip Schwarz
Plus de Philip Schwarz
(20)
Folding 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 Approaches
Tagless 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 Views
A 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 Scala
A 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 Cats
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...
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 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...
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 forData Oriented Programming - From Haskell and Scala t...
Algebraic Data Types forData 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 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 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 corrections
The Sieve of Eratosthenes - Part 1
The Sieve of Eratosthenes - Part 1
Dernier
EY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
Neo4j
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
VICTOR MAESTRE RAMIREZ
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
Evangelist Apps https://twitter.com/EvangelistSW/
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
OPEN KNOWLEDGE GmbH
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
Frank van der Linden
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
kaushalgiri8080
DNT_Corporate presentation know about us
DNT_Corporate presentation know about us
Dynamic Netsoft
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio, Inc.
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
kalichargn70th171
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
aagamshah0812
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
aditisharan08
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
stazi3110
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
kotipi9215
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
soniya singh
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
Intelisync
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
kalichargn70th171
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
OnePlan Solutions
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
Ortus Solutions, Corp
Dernier
(20)
EY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
DNT_Corporate presentation know about us
DNT_Corporate presentation know about us
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
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 𝑓𝑜𝑙𝑑𝑟:
3.
https://fpilluminated.com/ inspired by
Télécharger maintenant