Slide 1

Slide 1 text

CHEAT-SHEET Folding #1 ∢ / \ π’‚πŸŽ ∢ / \ π’‚πŸ ∢ / \ π’‚πŸ ∢ / \ π’‚πŸ‘ 𝒇 / \ π’‚πŸŽ 𝒇 / \ π’‚πŸ 𝒇 / \ π’‚πŸ 𝒇 / \ π’‚πŸ‘ 𝒆 @philip_schwarz slides by https://fpilluminated.com/

Slide 2

Slide 2 text

𝐝𝐚𝐭𝐚 𝑡𝒂𝒕 = 𝒁𝒆𝒓𝒐 | 𝑺𝒖𝒄𝒄 𝑡𝒂𝒕 𝐝𝐚𝐭𝐚 π‘³π’Šπ’”π’• Ξ± = π‘΅π’Šπ’ | π‘ͺ𝒐𝒏𝒔 Ξ± (π‘³π’Šπ’”π’• Ξ±) 𝑓 :: 𝑡𝒂𝒕 β†’ 𝛼 𝑓 𝒁𝒆𝒓𝒐 = 𝑐 𝑓 𝑺𝒖𝒄𝒄 𝑛 = β„Ž 𝑓 𝑛 π‘“π‘œπ‘™π‘‘π‘› ∷ 𝛼 β†’ 𝛼 β†’ 𝛼 β†’ 𝑡𝒂𝒕 β†’ 𝛼 π‘“π‘œπ‘™π‘‘π‘› β„Ž 𝑐 𝒁𝒆𝒓𝒐 = 𝑐 π‘“π‘œπ‘™π‘‘π‘› β„Ž 𝑐 𝑺𝒖𝒄𝒄 𝑛 = β„Ž π‘“π‘œπ‘™π‘‘π‘› β„Ž 𝑐 𝑛 π‘š + 𝑛 = π‘“π‘œπ‘™π‘‘π‘› 𝑺𝒖𝒄𝒄 π‘š 𝑛 π‘š Γ— 𝑛 = π‘“π‘œπ‘™π‘‘π‘› πœ†π‘₯. π‘₯ + π‘š 𝒁𝒆𝒓𝒐 𝑛 π‘š ↑ 𝑛 = π‘“π‘œπ‘™π‘‘π‘› πœ†π‘₯. π‘₯ Γ— π‘š 𝑺𝒖𝒄𝒄 𝒁𝒆𝒓𝒐 𝑛 + ∷ 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕 π‘š + 𝒁𝒆𝒓𝒐 = π‘š π‘š + 𝑺𝒖𝒄𝒄 𝑛 = 𝑺𝒖𝒄𝒄 π‘š + 𝑛 (Γ—) ∷ 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕 π‘š Γ— 𝒁𝒆𝒓𝒐 = 𝒁𝒆𝒓𝒐 π‘š Γ— 𝑺𝒖𝒄𝒄 𝑛 = π‘š Γ— 𝑛 + π‘š (↑) ∷ 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕 π‘š ↑ 𝒁𝒆𝒓𝒐 = 𝑺𝒖𝒄𝒄 𝒁𝒆𝒓𝒐 π‘š ↑ 𝑺𝒖𝒄𝒄 𝑛 = π‘š ↑ 𝑛 Γ— π‘š π‘“π‘œπ‘™π‘‘π‘Ÿ ∷ 𝛼 β†’ 𝛽 β†’ 𝛽 β†’ 𝛽 β†’ 𝛼 β†’ 𝛽 π‘“π‘œπ‘™π‘‘π‘Ÿ 𝑓 𝑏 π‘΅π’Šπ’ = 𝑏 π‘“π‘œπ‘™π‘‘π‘Ÿ 𝑓 𝑏 (π‘ͺ𝒐𝒏𝒔 π‘₯ π‘₯𝑠) = 𝑓 π‘₯ π‘“π‘œπ‘™π‘‘π‘Ÿ 𝑓 𝑏 π‘₯𝑠 𝑓 :: π‘³π’Šπ’”π’• 𝛼 β†’ 𝛽 𝑓 π‘΅π’Šπ’ = 𝑐 𝑓 π‘ͺ𝒐𝒏𝒔 π‘₯ π‘₯𝑠 = β„Ž π‘₯ (𝑓 π‘₯𝑠) π‘ π‘’π‘š ∷ π‘³π’Šπ’”π’• 𝑡𝒂𝒕 β†’ 𝑡𝒂𝒕 π‘ π‘’π‘š π‘΅π’Šπ’ = 𝒁𝒆𝒓𝒐 π‘ π‘’π‘š π‘ͺ𝒐𝒏𝒔 π‘₯ π‘₯𝑠 = π‘₯ + (π‘ π‘’π‘š π‘₯𝑠) π‘Žπ‘π‘π‘’π‘›π‘‘ ∷ π‘³π’Šπ’”π’• 𝛼 β†’ π‘³π’Šπ’”π’• 𝛼 β†’ π‘³π’Šπ’”π’• 𝛼 π‘Žπ‘π‘π‘’π‘›π‘‘ π‘΅π’Šπ’ 𝑦𝑠 = 𝑦𝑠 π‘Žπ‘π‘π‘’π‘›π‘‘ π‘ͺ𝒐𝒏𝒔 π‘₯ π‘₯𝑠 𝑦𝑠 = π‘ͺ𝒐𝒏𝒔 π‘₯ (π‘Žπ‘π‘π‘’π‘›π‘‘ π‘₯𝑠 𝑦𝑠) π‘™π‘’π‘›π‘”π‘‘β„Ž ∷ π‘³π’Šπ’”π’• 𝛼 β†’ 𝑡𝒂𝒕 π‘™π‘’π‘›π‘”π‘‘β„Ž π‘΅π’Šπ’ = 𝒁𝒆𝒓𝒐 π‘™π‘’π‘›π‘”π‘‘β„Ž π‘ͺ𝒐𝒏𝒔 π‘₯ π‘₯𝑠 = 𝑺𝒖𝒄𝒄 𝒁𝒆𝒓𝒐 + (π‘™π‘’π‘›π‘”π‘‘β„Ž π‘₯𝑠) π‘ π‘’π‘š π‘₯𝑠 = π‘“π‘œπ‘™π‘‘π‘Ÿ + 𝒁𝒆𝒓𝒐 π‘₯𝑠 π‘™π‘’π‘›π‘”π‘‘β„Ž π‘₯𝑠 = π‘“π‘œπ‘™π‘‘π‘Ÿ πœ†π‘₯. πœ†π‘›. 𝑛 + 𝑺𝒖𝒄𝒄 𝒁𝒆𝒓𝒐 𝒁𝒆𝒓𝒐 π‘₯𝑠 π‘Žπ‘π‘π‘’π‘›π‘‘ π‘₯𝑠 𝑦𝑠 = π‘“π‘œπ‘™π‘‘π‘Ÿ π‘ͺ𝒐𝒏𝒔 𝑦𝑠 π‘₯𝑠 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 π‘“π‘œπ‘™π‘‘π‘Ÿ:

Slide 3

Slide 3 text

https://fpilluminated.com/ inspired by