SlideShare a Scribd company logo
CHEAT-SHEET
Folding
#3
∶
/ 
𝒂𝟎 ∶
/ 
𝒂𝟏 ∶
/ 
𝒂𝟐 ∶
/ 
𝒂𝟑
𝒇
/ 
𝒂𝟎 𝒇
/ 
𝒂𝟏 𝒇
/ 
𝒂𝟐 𝒇
/ 
𝒂𝟑 𝒆
@philip_schwarz
slides by https://fpilluminated.com/
The universal property of 𝒇𝒐𝒍𝒅
...
For finite lists, the universal property of 𝒇𝒐𝒍𝒅 can be stated as the following equivalence between two definitions for a function 𝒈 that
processes lists:
𝒈 = 𝒗 ⟺ 𝒈 = 𝒇𝒐𝒍𝒅 𝒇 𝒗
𝒈 𝑥 ∶ 𝑥𝑠 = 𝒇 𝑥 𝒈 𝑥𝑠
In the right-to-left direction, substituting 𝒈 = 𝒇𝒐𝒍𝒅 𝒇 𝒗 into the two equations for 𝒈 gives the recursive definition for 𝒇𝒐𝒍𝒅.
Conversely, in the left-to-right direction the two equations for g are precisely the assumptions required to show that 𝒈 = 𝒇𝒐𝒍𝒅 𝒇 𝒗 using a
simple proof by induction on finite lists…
Taken as a whole, the universal property states that for finite lists the function 𝒇𝒐𝒍𝒅 𝒇 𝒗 is not just a solution to its defining equations, but
in fact the unique solution….
The universal property of 𝒇𝒐𝒍𝒅 can be generalised to handle partial and infinite lists…
Graham Hutton
@haskelhutt
𝑓𝑜𝑙𝑑 :: 𝛼 → 𝛽 → 𝛽 → 𝛽 → 𝛼 → 𝛽
𝑓𝑜𝑙𝑑 𝑓 𝑣 = 𝑣
𝑓𝑜𝑙𝑑 𝑓 𝑣 𝑥 ∶ 𝑥𝑠 = 𝑓 𝑥 𝑓𝑜𝑙𝑑 𝑓 𝑣 𝑥𝑠
𝑔 = 𝑣
𝑔 𝑥 ∶ 𝑥𝑠 = 𝑓 𝑥 𝑔 𝑥𝑠
𝑠𝑢𝑚 ∷ 𝐼𝑛𝑡 → 𝐼𝑛𝑡
𝑠𝑢𝑚 = 0
𝑠𝑢𝑚 𝑥 ∶ 𝑥𝑠 = 𝑥 + 𝑠𝑢𝑚 𝑥𝑠
𝑠𝑢𝑚 = 𝑓𝑜𝑙𝑑 + 0
⟺
𝑔 = 𝑓𝑜𝑙𝑑 𝑓 𝑣
⟺
𝑝𝑟𝑜𝑑𝑢𝑐𝑡 ∷ 𝐼𝑛𝑡 → 𝐼𝑛𝑡
𝑝𝑟𝑜𝑑𝑢𝑐𝑡 = 1
𝑝𝑟𝑜𝑑𝑢𝑐𝑡 𝑥 ∶ 𝑥𝑠 = 𝑥 × 𝑝𝑟𝑜𝑑𝑢𝑐𝑡 𝑥𝑠
𝑝𝑟𝑜𝑑𝑢𝑐𝑡 = 𝑓𝑜𝑙𝑑 (×) 1
⟺
𝑙𝑒𝑛𝑔𝑡ℎ ∷ [α] → 𝐼𝑛𝑡
𝑙𝑒𝑛𝑔𝑡ℎ [ ] = 0
𝑙𝑒𝑛𝑔𝑡ℎ 𝑥 ∶ 𝑥𝑠 = 1 + 𝑙𝑒𝑛𝑔𝑡ℎ 𝑥𝑠
𝑙𝑒𝑛𝑔𝑡ℎ = 𝑓𝑜𝑙𝑑 (𝜆𝑥. 𝜆𝑛. 1 + 𝑛) 0
⟺
(⧺) ∷ [α] → [α] → [α]
⧺ 𝑦𝑠 = 𝑦𝑠
𝑥 ∶ 𝑥𝑠 ⧺ 𝑦𝑠 = 𝑥 ∶ (𝑥𝑠 ⧺ 𝑦𝑠)
(⧺ 𝑦𝑠) = 𝑓𝑜𝑙𝑑 ∶ 𝑦𝑠
⟺
concat ∷ [ α ] → [α]
concat =
concat 𝑥𝑠 ∶ 𝑥𝑠𝑠 = 𝑥𝑠 ⧺ 𝑐𝑜𝑛𝑐𝑎𝑡 𝑥𝑠𝑠
⟺ concat = 𝑓𝑜𝑙𝑑 (⧺) [ ]
The Triad of
𝑚𝑎𝑝, 𝑓𝑖𝑙𝑡𝑒𝑟 and 𝑓𝑜𝑙𝑑
𝑚𝑎𝑝
λ
The 𝑏𝑟𝑒𝑎𝑑, 𝑏𝑢𝑡𝑡𝑒𝑟, and 𝑗𝑎𝑚 of
Functional Programming
=
𝑔 = 𝑣
𝑔 𝑥 ∶ 𝑥𝑠 = 𝑓 𝑥 𝑔 𝑥𝑠
𝑚𝑎𝑝 ∷ 𝛼 → 𝛽 → 𝛼 → 𝛽
𝑚𝑎𝑝 𝑓 =
𝑚𝑎𝑝 𝑓 𝑥 ∶ 𝑥𝑠 = 𝑓 𝑥 ∶ 𝑚𝑎𝑝 𝑓 𝑥𝑠
𝑚𝑎𝑝 𝑓 = 𝑓𝑜𝑙𝑑𝑟 𝜆𝑥. 𝜆𝑥𝑠. 𝑓 𝑥 ∶ 𝑥𝑠 [ ]
⟺
𝑓𝑖𝑙𝑡𝑒𝑟 ∷ (𝛼 → 𝐵𝑜𝑜𝑙) → 𝛼 → 𝑎
𝑓𝑖𝑙𝑡𝑒𝑟 p =
𝑓𝑖𝑙𝑡𝑒𝑟 p 𝑥 ∶ 𝑥𝑠 = 𝐢𝐟 𝑝 𝑥
𝐭𝐡𝐞𝐧 𝑥 ∶ 𝑓𝑖𝑙𝑡𝑒𝑟 p 𝑥𝑠
𝐞𝐥𝐬𝐞 𝑓𝑖𝑙𝑡𝑒𝑟 p 𝑥𝑠
𝑓𝑖𝑙𝑡𝑒𝑟 p = 𝑓𝑜𝑙𝑑𝑟 (𝜆𝑥. 𝜆𝑥𝑠. 𝐢𝐟 𝑝 𝑥 𝐭𝐡𝐞𝐧 𝑥 ∶ 𝑥𝑠 𝐞𝐥𝐬𝐞 𝑥𝑠) [ ]
⟺
𝑔 = 𝑓𝑜𝑙𝑑𝑟 𝑓 𝑣
⟺
𝑚𝑎𝑝
λ
𝑓𝑜𝑙𝑑
=
https://fpilluminated.com/
inspired
by

More Related Content

Similar to Folding Cheat Sheet #3 - third in a series (20)

PDF
Basic calculus (i)
Farzad Javidanrad
 
PPTX
Complex differentiation contains analytic function.pptx
jyotidighole2
 
PDF
Module 7 the antiderivative
REYEMMANUELILUMBA
 
PDF
Module 7 the antiderivative
REYEMMANUELILUMBA
 
PDF
Application of Convolution Theorem
ijtsrd
 
PPTX
PRODUCT RULES
NumanUsama
 
PPTX
Laplace Transform and its applications
DeepRaval7
 
PPTX
Domain-Range-Intercepts-Zeros-and-Asymptotes-of-Rational-Function.pptx
NeomyAngelaLeono1
 
PDF
Taller grupal parcial ii nrc 3246 sebastian fueltala_kevin sánchez
kevinct2001
 
PDF
C222529
irjes
 
PDF
Dual Spaces of Generalized Cesaro Sequence Space and Related Matrix Mapping
inventionjournals
 
PDF
Matrix Transformations on Some Difference Sequence Spaces
IOSR Journals
 
PDF
Integrales definidas y método de integración por partes
crysmari mujica
 
PDF
A PROBABILISTIC ALGORITHM FOR COMPUTATION OF POLYNOMIAL GREATEST COMMON WITH ...
mathsjournal
 
PDF
A Probabilistic Algorithm for Computation of Polynomial Greatest Common with ...
mathsjournal
 
PDF
A PROBABILISTIC ALGORITHM FOR COMPUTATION OF POLYNOMIAL GREATEST COMMON WITH ...
mathsjournal
 
PDF
Typesetting Mathematics with LaTeX - Day 2
Suddhasheel GHOSH, PhD
 
PDF
Differential Geometry for Machine Learning
SEMINARGROOT
 
PPTX
SPLIT PLOT DESIGN new.pptx
ValeDiode
 
Basic calculus (i)
Farzad Javidanrad
 
Complex differentiation contains analytic function.pptx
jyotidighole2
 
Module 7 the antiderivative
REYEMMANUELILUMBA
 
Module 7 the antiderivative
REYEMMANUELILUMBA
 
Application of Convolution Theorem
ijtsrd
 
PRODUCT RULES
NumanUsama
 
Laplace Transform and its applications
DeepRaval7
 
Domain-Range-Intercepts-Zeros-and-Asymptotes-of-Rational-Function.pptx
NeomyAngelaLeono1
 
Taller grupal parcial ii nrc 3246 sebastian fueltala_kevin sánchez
kevinct2001
 
C222529
irjes
 
Dual Spaces of Generalized Cesaro Sequence Space and Related Matrix Mapping
inventionjournals
 
Matrix Transformations on Some Difference Sequence Spaces
IOSR Journals
 
Integrales definidas y método de integración por partes
crysmari mujica
 
A PROBABILISTIC ALGORITHM FOR COMPUTATION OF POLYNOMIAL GREATEST COMMON WITH ...
mathsjournal
 
A Probabilistic Algorithm for Computation of Polynomial Greatest Common with ...
mathsjournal
 
A PROBABILISTIC ALGORITHM FOR COMPUTATION OF POLYNOMIAL GREATEST COMMON WITH ...
mathsjournal
 
Typesetting Mathematics with LaTeX - Day 2
Suddhasheel GHOSH, PhD
 
Differential Geometry for Machine Learning
SEMINARGROOT
 
SPLIT PLOT DESIGN new.pptx
ValeDiode
 

More from Philip Schwarz (20)

PDF
Folding Cheat Sheet Series Titles - a series of 9 decks
Philip Schwarz
 
PDF
Folding Cheat Sheet # 9 - List Unfolding 𝑢𝑛𝑓𝑜𝑙𝑑 as the Computational Dual of ...
Philip Schwarz
 
PDF
Drawing Heighway’s Dragon - Part 4 - Interactive and Animated Dragon Creation
Philip Schwarz
 
PDF
The Nature of Complexity in John Ousterhout’s Philosophy of Software Design
Philip Schwarz
 
PDF
Drawing Heighway’s Dragon - Part 3 - Simplification Through Separation of Con...
Philip Schwarz
 
PDF
The Open-Closed Principle - Part 2 - The Contemporary Version - An Introduction
Philip Schwarz
 
PDF
The Open-Closed Principle - Part 1 - The Original Version
Philip Schwarz
 
PDF
Drawing Heighway’s Dragon - Part II - Recursive Function Simplification - Fro...
Philip Schwarz
 
PDF
Drawing Heighway’s Dragon - Recursive Function Rewrite - From Imperative Styl...
Philip Schwarz
 
PDF
Fibonacci Function Gallery - Part 2 - One in a series
Philip Schwarz
 
PDF
Fibonacci Function Gallery - Part 1 (of a series) - with minor corrections
Philip Schwarz
 
PDF
Fibonacci Function Gallery - Part 1 (of a series)
Philip Schwarz
 
PDF
The Debt Metaphor - Ward Cunningham in his 2009 YouTube video
Philip Schwarz
 
PDF
Folding Cheat Sheet Series Titles (so far)
Philip Schwarz
 
PDF
From Subtype Polymorphism To Typeclass-based Ad hoc Polymorphism - An Example
Philip Schwarz
 
PDF
Folding Cheat Sheet #8 - eighth in a series
Philip Schwarz
 
PDF
Function Applicative for Great Good of Leap Year Function
Philip Schwarz
 
PDF
Folding Cheat Sheet #7 - seventh in a series
Philip Schwarz
 
PDF
Folding Cheat Sheet #6 - sixth in a series
Philip Schwarz
 
PDF
Folding Cheat Sheet #5 - fifth in a series
Philip Schwarz
 
Folding Cheat Sheet Series Titles - a series of 9 decks
Philip Schwarz
 
Folding Cheat Sheet # 9 - List Unfolding 𝑢𝑛𝑓𝑜𝑙𝑑 as the Computational Dual of ...
Philip Schwarz
 
Drawing Heighway’s Dragon - Part 4 - Interactive and Animated Dragon Creation
Philip Schwarz
 
The Nature of Complexity in John Ousterhout’s Philosophy of Software Design
Philip Schwarz
 
Drawing Heighway’s Dragon - Part 3 - Simplification Through Separation of Con...
Philip Schwarz
 
The Open-Closed Principle - Part 2 - The Contemporary Version - An Introduction
Philip Schwarz
 
The Open-Closed Principle - Part 1 - The Original Version
Philip Schwarz
 
Drawing Heighway’s Dragon - Part II - Recursive Function Simplification - Fro...
Philip Schwarz
 
Drawing Heighway’s Dragon - Recursive Function Rewrite - From Imperative Styl...
Philip Schwarz
 
Fibonacci Function Gallery - Part 2 - One in a series
Philip Schwarz
 
Fibonacci Function Gallery - Part 1 (of a series) - with minor corrections
Philip Schwarz
 
Fibonacci Function Gallery - Part 1 (of a series)
Philip Schwarz
 
The Debt Metaphor - Ward Cunningham in his 2009 YouTube video
Philip Schwarz
 
Folding Cheat Sheet Series Titles (so far)
Philip Schwarz
 
From Subtype Polymorphism To Typeclass-based Ad hoc Polymorphism - An Example
Philip Schwarz
 
Folding Cheat Sheet #8 - eighth in a series
Philip Schwarz
 
Function Applicative for Great Good of Leap Year Function
Philip Schwarz
 
Folding Cheat Sheet #7 - seventh in a series
Philip Schwarz
 
Folding Cheat Sheet #6 - sixth in a series
Philip Schwarz
 
Folding Cheat Sheet #5 - fifth in a series
Philip Schwarz
 
Ad

Recently uploaded (20)

PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
Ad

Folding Cheat Sheet #3 - third in a series

  • 1. CHEAT-SHEET Folding #3 ∶ / 𝒂𝟎 ∶ / 𝒂𝟏 ∶ / 𝒂𝟐 ∶ / 𝒂𝟑 𝒇 / 𝒂𝟎 𝒇 / 𝒂𝟏 𝒇 / 𝒂𝟐 𝒇 / 𝒂𝟑 𝒆 @philip_schwarz slides by https://fpilluminated.com/
  • 2. The universal property of 𝒇𝒐𝒍𝒅 ... For finite lists, the universal property of 𝒇𝒐𝒍𝒅 can be stated as the following equivalence between two definitions for a function 𝒈 that processes lists: 𝒈 = 𝒗 ⟺ 𝒈 = 𝒇𝒐𝒍𝒅 𝒇 𝒗 𝒈 𝑥 ∶ 𝑥𝑠 = 𝒇 𝑥 𝒈 𝑥𝑠 In the right-to-left direction, substituting 𝒈 = 𝒇𝒐𝒍𝒅 𝒇 𝒗 into the two equations for 𝒈 gives the recursive definition for 𝒇𝒐𝒍𝒅. Conversely, in the left-to-right direction the two equations for g are precisely the assumptions required to show that 𝒈 = 𝒇𝒐𝒍𝒅 𝒇 𝒗 using a simple proof by induction on finite lists… Taken as a whole, the universal property states that for finite lists the function 𝒇𝒐𝒍𝒅 𝒇 𝒗 is not just a solution to its defining equations, but in fact the unique solution…. The universal property of 𝒇𝒐𝒍𝒅 can be generalised to handle partial and infinite lists… Graham Hutton @haskelhutt 𝑓𝑜𝑙𝑑 :: 𝛼 → 𝛽 → 𝛽 → 𝛽 → 𝛼 → 𝛽 𝑓𝑜𝑙𝑑 𝑓 𝑣 = 𝑣 𝑓𝑜𝑙𝑑 𝑓 𝑣 𝑥 ∶ 𝑥𝑠 = 𝑓 𝑥 𝑓𝑜𝑙𝑑 𝑓 𝑣 𝑥𝑠
  • 3. 𝑔 = 𝑣 𝑔 𝑥 ∶ 𝑥𝑠 = 𝑓 𝑥 𝑔 𝑥𝑠 𝑠𝑢𝑚 ∷ 𝐼𝑛𝑡 → 𝐼𝑛𝑡 𝑠𝑢𝑚 = 0 𝑠𝑢𝑚 𝑥 ∶ 𝑥𝑠 = 𝑥 + 𝑠𝑢𝑚 𝑥𝑠 𝑠𝑢𝑚 = 𝑓𝑜𝑙𝑑 + 0 ⟺ 𝑔 = 𝑓𝑜𝑙𝑑 𝑓 𝑣 ⟺ 𝑝𝑟𝑜𝑑𝑢𝑐𝑡 ∷ 𝐼𝑛𝑡 → 𝐼𝑛𝑡 𝑝𝑟𝑜𝑑𝑢𝑐𝑡 = 1 𝑝𝑟𝑜𝑑𝑢𝑐𝑡 𝑥 ∶ 𝑥𝑠 = 𝑥 × 𝑝𝑟𝑜𝑑𝑢𝑐𝑡 𝑥𝑠 𝑝𝑟𝑜𝑑𝑢𝑐𝑡 = 𝑓𝑜𝑙𝑑 (×) 1 ⟺ 𝑙𝑒𝑛𝑔𝑡ℎ ∷ [α] → 𝐼𝑛𝑡 𝑙𝑒𝑛𝑔𝑡ℎ [ ] = 0 𝑙𝑒𝑛𝑔𝑡ℎ 𝑥 ∶ 𝑥𝑠 = 1 + 𝑙𝑒𝑛𝑔𝑡ℎ 𝑥𝑠 𝑙𝑒𝑛𝑔𝑡ℎ = 𝑓𝑜𝑙𝑑 (𝜆𝑥. 𝜆𝑛. 1 + 𝑛) 0 ⟺ (⧺) ∷ [α] → [α] → [α] ⧺ 𝑦𝑠 = 𝑦𝑠 𝑥 ∶ 𝑥𝑠 ⧺ 𝑦𝑠 = 𝑥 ∶ (𝑥𝑠 ⧺ 𝑦𝑠) (⧺ 𝑦𝑠) = 𝑓𝑜𝑙𝑑 ∶ 𝑦𝑠 ⟺ concat ∷ [ α ] → [α] concat = concat 𝑥𝑠 ∶ 𝑥𝑠𝑠 = 𝑥𝑠 ⧺ 𝑐𝑜𝑛𝑐𝑎𝑡 𝑥𝑠𝑠 ⟺ concat = 𝑓𝑜𝑙𝑑 (⧺) [ ]
  • 4. The Triad of 𝑚𝑎𝑝, 𝑓𝑖𝑙𝑡𝑒𝑟 and 𝑓𝑜𝑙𝑑 𝑚𝑎𝑝 λ The 𝑏𝑟𝑒𝑎𝑑, 𝑏𝑢𝑡𝑡𝑒𝑟, and 𝑗𝑎𝑚 of Functional Programming =
  • 5. 𝑔 = 𝑣 𝑔 𝑥 ∶ 𝑥𝑠 = 𝑓 𝑥 𝑔 𝑥𝑠 𝑚𝑎𝑝 ∷ 𝛼 → 𝛽 → 𝛼 → 𝛽 𝑚𝑎𝑝 𝑓 = 𝑚𝑎𝑝 𝑓 𝑥 ∶ 𝑥𝑠 = 𝑓 𝑥 ∶ 𝑚𝑎𝑝 𝑓 𝑥𝑠 𝑚𝑎𝑝 𝑓 = 𝑓𝑜𝑙𝑑𝑟 𝜆𝑥. 𝜆𝑥𝑠. 𝑓 𝑥 ∶ 𝑥𝑠 [ ] ⟺ 𝑓𝑖𝑙𝑡𝑒𝑟 ∷ (𝛼 → 𝐵𝑜𝑜𝑙) → 𝛼 → 𝑎 𝑓𝑖𝑙𝑡𝑒𝑟 p = 𝑓𝑖𝑙𝑡𝑒𝑟 p 𝑥 ∶ 𝑥𝑠 = 𝐢𝐟 𝑝 𝑥 𝐭𝐡𝐞𝐧 𝑥 ∶ 𝑓𝑖𝑙𝑡𝑒𝑟 p 𝑥𝑠 𝐞𝐥𝐬𝐞 𝑓𝑖𝑙𝑡𝑒𝑟 p 𝑥𝑠 𝑓𝑖𝑙𝑡𝑒𝑟 p = 𝑓𝑜𝑙𝑑𝑟 (𝜆𝑥. 𝜆𝑥𝑠. 𝐢𝐟 𝑝 𝑥 𝐭𝐡𝐞𝐧 𝑥 ∶ 𝑥𝑠 𝐞𝐥𝐬𝐞 𝑥𝑠) [ ] ⟺ 𝑔 = 𝑓𝑜𝑙𝑑𝑟 𝑓 𝑣 ⟺ 𝑚𝑎𝑝 λ 𝑓𝑜𝑙𝑑 =