• tetris11@feddit.uk
    link
    fedilink
    English
    arrow-up
    5
    ·
    edit-2
    6 hours ago

    The Fixed Point Expression / Y Combinator expressed in horses:

        Y = (λ f. (λ x. f(xx))(λ x. f(xx)))
        ;; so then, give Y a horse argument with apple parameters:
        Y🐎️ = (λ f. (λ 🍎.  f(🍎🍎)) (λ 🍎. f(🍎🍎))) 🐎️   ;; [1]
            =       (λ 🍎. 🐎️(🍎🍎)) (λ 🍎. 🐎️(🍎🍎))      ;; [2]
            = 🐎️(   (λ 🍎. 🐎️(🍎🍎)) (λ 🍎. 🐎️(🍎🍎))   )  ;; [3]
            = 🐎️(Y🐎️)                                       ;; [4]
    
    Explanation
    • 1: x is 🍎, but could be anything. It’s just a function parameter nested within another.
    • 2: λf gets executed and vanishes from the left, substituting f internally with 🐎️. This is now a new function, with left group as the function body, and right group as the function argument, despite being identical.
    • 3: λ🍎 gets executed and vanishes from the left, substituting 🍎 with (λ 🍎. 🐎️(🍎🍎))
    • 4: Everything within the main brackets at [3] has been seen before at [1], but with f being 🐎. Thus we have bred a new horse. We can breed infinite horses this way