Mathieu Ledru
April 25, 2023
620

# Y-Combinator in PHP

This talk is about Y-Combinator and implementation in PHP

Article associated to this talk

https://blog.darkwood.fr/article/y-combinator-en-php

Video associated to this talk

April 25, 2023

## Transcript

2. ### ⾠ I’m not an expert ⾠ I will speak with

my own words @matyo91 @matyo91 25-04-2023
3. ### Objectives : Go back up to theoretical concepts that solve

an issue How I discovered Y-Combinator and why I do need them ? Why Y-Combinator ? Introduction to Lambda Calculus Exemples of basic Lambda Calculus and equivalent in PHP Y-Combinator in PHP (for me and others github repositories) Plan @matyo91 25-04-2023 @matyo91

them ?
5. ### In PHP https://github.com/darkwood-fr/flow In PHP https://github.com/phpflo/phpflo 25-04-2023 Flow Based Railway

Flow Based MulByTwo MinusThree AddOne @matyo91

7. ### Do recursion in a language that do not have any

recursion mechanism at all “ @matyo91 25-04-2023

10. ### A Y-combinator is a "functional" (a function that operates on

other functions) that enables recursion, when you can't refer to the function from within itself. In computer-science theory, it generalises recursion, abstracting its implementation, and thereby separating it from the actual work of the function in question. This is applicable in languages that support Lambda-Calculus functions Y-Combinator @matyo91 25-04-2023 @matyo91

12. ### Alonzo Church ( 1903 - 1995 ) Inventor of Lambda

Calculus @matyo91 @matyo91 25-04-2023

14. ### λ x . x + 1 ( λ x .

x + 1 ) ( 5 ) = 5 + 1 = 6 @matyo91 @matyo91 25-04-2023 X X + 1
15. ### λ x . λ y . x+y     (

λ x . λ y . x+y ) ( 5 , 6 ) = 5 + 6 = 11 @matyo91 @matyo91 25-04-2023 X X + Y Y
16. ### There are variables. We got a way to build functions.

We can apply functions to each others by providing elements of the language itself. All derivatives of lambda calculus language is something defined in terms of this definition. Lambda Calculus @matyo91 25-04-2023 @matyo91

19. ### True = λ x . λ y . x False

= λ x . λ y . y @matyo91 @matyo91 25-04-2023 X X Y True X Y Y False
20. ### True = λ x . λ y . x @matyo91

@matyo91 25-04-2023 False = λ x . λ y . y

23. ### Not = λ b . b False True @matyo91 @matyo91

25-04-2023 b False True b Not
24. ### Not = ( λ b . b False True )

( True ) = True False True = ( λ x . λ y . x ) ( False True ) = False @matyo91 @matyo91 25-04-2023

True

27. ### Y ( f ) = f ( Y ( f

) ) = f ( f ( Y ( f ) ) ) = f ( f ( f ( f ( ... ) ) ) ) @matyo91 @matyo91 25-04-2023
28. ### Fac (n) = if n == 1 then 1 else

n * Fac (n - 1)   Fac (3) = 3 * Fac (2) = 3 * 2 * Fac (1) = 3 * 2 * 1 = 6 @matyo91 @matyo91 25-04-2023 YCombinator in Lambda Calculus
29. ### Fac = Y ( ? ) @matyo91 @matyo91 25-04-2023 YCombinator

in Lambda Calculus
30. ### Fac = Y ( ? ) = Y ( λ

f . λ n . ? ) = Y ( λ f . λ n . max( n , 1 ) * Fac ( n - 1 ) ) @matyo91 @matyo91 25-04-2023 YCombinator in Lambda Calculus

33. ### Loop = ( λ x . x . x )

( λ x . x . x ) @matyo91 @matyo91 25-04-2023 YCombinator in Lambda Calculus
34. ### Loop = ( λ x . x . x )

( λ x . x . x ) @matyo91 @matyo91 25-04-2023 YCombinator in Lambda Calculus
35. ### Loop = ( λ x . x . x )

( λ x . x . x ) Loop = ( λ x . ( λ x . x . x ) . ( λ x . x . x ) ) @matyo91 @matyo91 25-04-2023 YCombinator in Lambda Calculus
36. ### Loop = ( λ x . x . x )

( λ x . x . x ) Loop = ( λ x . ( λ x . x . x ) . ( λ x . x . x ) ) Loop = ( λ x . x . x ) ( λ x . x . x ) @matyo91 @matyo91 25-04-2023 YCombinator in Lambda Calculus
37. ### Loop = Y ( ? ) @matyo91 @matyo91 25-04-2023 YCombinator

in Lambda Calculus
38. ### Loop = Y ( λ x . x . x

) = ( λ x . x . x ) ( Y ( λ x . x . x ) ) = ( λ x . x . x ) ( λ x . x . x ) ( Y ( λ x . x . x ) ) @matyo91 @matyo91 25-04-2023 YCombinator in Lambda Calculus
39. ### Y ( f ) = λ f ( λ x

. f ( x x ) ) ( λ x . f ( x x ) ) @matyo91 @matyo91 25-04-2023 YCombinator in Lambda Calculus

44. ### Hello! I Am Mathieu Ledru You can contact me at

@matyo91 25-04-2023 @matyo91 Thanks! Any questions?