Understanding the Y Combinator
8dcc.github.io
Understanding the Y Combinator
1–10 of 73 posts
Re: Understanding the Y Combinator
#2Re: Understanding the Y Combinator
#3I know it's cool, and useful to know, but I just can't get there. Maybe it's a stack overflow in my head?
Is it just me?
[Edit] Re:082349872349872 - I grew up in a world of assembler programming, BASIC and Pascal. It wasn't unusual to have all sorts of self-interacting code, and deliberate use of the same half of a routine in more than one function.
I get why Lambda is useful, why bother naming a function you're only going to use once. But it seemed like infinite pedantry to go about using it to do recursion... thanks!
[Edit2] Re:082349872349872 - I once came upon old code that lived in a S-100 disk controller, it seemed really weird until I realized they couldn't call a subroutine because they couldn't assume there was a properly set stack. It used one of the 8080 registers as a return pointer.
Re: Understanding the Y Combinator
#4> 8. Applications of the Y combinator
> You might be wondering what makes the Y combinator so special.
Re: Understanding the Y Combinator
#5 fac = λn.λf.n(λf.λn.n(f(λf.λx.n f(f x))))(λx.f)(λx.x)
For example, applied to Church numeral 3 this gives (with F=(λf.λn.n(f(λf.λx.n f(f x))))): fac 3 = \f. F (F (F (\x.f))) 1
= \f. 1 (F (F (\x.f)) 2)
= \f. 1 (2 (F (\x.f) 3))
= \f. 1 (2 (3 ((\x.f) 4)))
= \f. 1 (2 (3 f))
which is the Church numeral for 1*2*3 = 6.Re: Understanding the Y Combinator
#6I'd really like to understand why my brain screams NO when I try to grok lisp and especially the Y combinator. It's like it's anti-interesting to me or something. I know it's cool, and useful to know, but I just can't get there. Maybe it's a stack overflow in my head? Is it just me? [Edit] Re:082349872349872 - I grew up in a world of assembler programming, BASIC and Pascal. It wasn't unusual to have all sorts of self…
But your profile says you have been programming since 1979, so I humbly defer to your experience. If you have made it this far without Lisp, I guess you don't need it, friend :-)
Take it from a younger programmer, you don't have to grok lambda calculus to understand Lisp. I like Lisp, but I only have a vague notion of lambda calculus and all that academic gobbledygook. I still do not understand the Y combinator, nor I very much care to. CS theory is good and all, but it's importance is often overstated. Physicists are not engineers and engineers are not physicists; you can be a very effective programmer without knowing about Peano numbers and what monads are.
Re: Understanding the Y Combinator
#7I'd really like to understand why my brain screams NO when I try to grok lisp and especially the Y combinator. It's like it's anti-interesting to me or something. I know it's cool, and useful to know, but I just can't get there. Maybe it's a stack overflow in my head? Is it just me? [Edit] Re:082349872349872 - I grew up in a world of assembler programming, BASIC and Pascal. It wasn't unusual to have all sorts of self…
However, if you're a pedant, and only accept definitions that are in terms of things other than themselves, then you'll need something like the Y combinator to even define, let alone invoke, recursive functions.
(there was a period* of a decade or two where systems people wrote recursive functions and theory people said "yes, it works in practice, but does it work in theory?", but now even theorists have a pedantic way to both describe functions in terms of themselves [syntactically] and agree that such a description denotes a unique function [semantically], so now we have our cake and eat it: a toolchain will go right ahead and generate fixups for the object that point back into itself, while a thesis will drop names like Tarski or Brouwer and maybe typeset another greek character or two)
* which may have overlapped with the period where people preferred one-pass to two-pass tools because manually stuffing paper tape back into the reader between passes was a pain?
EDIT: extreme pedantry: it surprises me that there was also a decade or so between LABEL and LABELS; going from single recursion to mutual recursion is a very small change in the underlying interpreters, yet even lispers were too pragmatic to have bothered to do so.
EDIT2: upon reflection, this was also the period of time where having a stack was viewed as a complexity which was certainly convenient but not exactly necessary. With the benefit of hindsight, I'd argue that mutual tail recursion is useful even without a stack, but can see that at the time that might've been viewed as architecture astronaut talk.
Re: Understanding the Y Combinator
#8Well, I have to confess I was misled by the title! I was under the impression that the article was about YC, but it turned out to be about mathematics. Ironically, the below quote is still relevant to YC, I believe: > 8. Applications of the Y combinator > You might be wondering what makes the Y combinator so special.
Re: Understanding the Y Combinator
#9Note that with the standard representation of natural numbers in lambda calculus, the Church numerals [1], you don't even need the Y combinator to implement factorial: fac = λn.λf.n(λf.λn.n(f(λf.λx.n f(f x))))(λx.f)(λx.x) For example, applied to Church numeral 3 this gives (with F=(λf.λn.n(f(λf.λx.n f(f x))))): fac 3 = \f. F (F (F (\x.f))) 1 = \f. 1 (F (F (\x.f)) 2) = \f. 1 (2 (F (\x.f) 3)) = \f. 1 (2 (3 ((\x.f) 4)))…
Am I missing something here or should I just go back to the basics?
Re: Understanding the Y Combinator
#10I'd really like to understand why my brain screams NO when I try to grok lisp and especially the Y combinator. It's like it's anti-interesting to me or something. I know it's cool, and useful to know, but I just can't get there. Maybe it's a stack overflow in my head? Is it just me? [Edit] Re:082349872349872 - I grew up in a world of assembler programming, BASIC and Pascal. It wasn't unusual to have all sorts of self…