In university, I had fun actually applying lambda calculus. Here’s a very silly python script. # a factorial function written entirely with just single-argumented lambdas # and calls fac = ((lambda p: p(p)(lambda q: lambda n: ((n(lambda e: lambda e: lambda a: a)(lambda i: lambda l: i))(lambda d: lambda c: c) (lambda m: (lambda m: lambda z: m(n(z)))(q(m)))((lambda c: lambda x: n(lambda g: lambda h: h(g(c)))(lambda u:…
You might enjoy this: https://flownet.com/ron/lambda-calculus.html
λ Calculus (2013) [pdf]
51–60 of 73 posts
Re: λ Calculus (2013) [pdf]
#52This PDF is an exerpt from the book Programming Distributed Computing Systems: A Foundational Approach by Professor Carlos Varela. He was my advisor at RPI, and one of the most pleasant professors I had the pleasure of interacting with during my time there. His classes were notoriously hard, but I enjoyed them very much. The full book includes very concise walk thoughs of various other less well known calculi and the…
Re: λ Calculus (2013) [pdf]
#53Earlier quoted context omitted.
The lambda calculus was never meant to be a "practical FP language"; it predates programming languages and even mechanical stored-program computers as we understand them.
What are the useful cases of the Y combinator then? (I don't say that the lambda calculus is useless, I was responding to a comment that claimed the lambda calculus is useless without the Y combinator.)
Re: λ Calculus (2013) [pdf]
#54For kids: http://worrydream.com/AlligatorEggs/ and: https://metatoys.org/alligator/
A lambda calculus calculator: https://lambster.dev/
A tetris style game for learning combinators: https://dirk.rave.org/combinatris/
Re: λ Calculus (2013) [pdf]
#55 |0| = λx. x
|n+1| = λ_. |n|
In other words, 0 is identity, and successor is the const function. This makes the predecessor function easy to define. Just apply Succ n to anything to get n back. The article fails to answer the most crucial question about these numerals though:Can we write a function that tests if a numeral represents 0? I.e. a function f such that
f |0| = True
f |n+1| = False
Equivalently, we can ask if it's possible to convert these numerals to Church numerals, the standard number representation in lambda calculus.
If one cannot, then these numerals don't seem to be useful in any way, and don't deserve to be called a number representation.This reminds me of someone proposing to represent the number n in combinatory logic with basis {S,K} as simply S^n K, i.e. using K as Zero and S as Successor. That one does turn out to be convertible to Church numerals [1].
Re: λ Calculus (2013) [pdf]
#56There are several games and other online resources for learning lambda calculus and combinators: For kids: http://worrydream.com/AlligatorEggs/ and: https://metatoys.org/alligator/ A lambda calculus calculator: https://lambster.dev/ A tetris style game for learning combinators: https://dirk.rave.org/combinatris/
Re: λ Calculus (2013) [pdf]
#57The number representation proposed by the author is one I've never seen before: |0| = λx. x |n+1| = λ_. |n| In other words, 0 is identity, and successor is the const function. This makes the predecessor function easy to define. Just apply Succ n to anything to get n back. The article fails to answer the most crucial question about these numerals though: Can we write a function that tests if a numeral represents 0? I.…
The expansion into |n|(args...) must happen before we know what n is, because in the lambda calculus we can't know anything about a function without calling it. Since it happens before we know what n is, then the number of args will necessarily be the same for all n. When n > numargs, |n|(args...) ignores all its arguments and halts, and therefore f cannot be a useful test for zero.
Re: λ Calculus (2013) [pdf]
#58What is the motivation for lambda calculus?
A little bit of historical background. There was a concerted effort in the late 19th, early 20th century (perhaps earlier too) to mechanise computation i.e., reducing it to a pure symbolic manipulation. There were obvious benefits, a famous one being Enigma Machine that was used to (successfully I think) break the German code during WW-2. On the philosophical side a parallel and overlapping effort was going on to fig…
Re: λ Calculus (2013) [pdf]
#59The number representation proposed by the author is one I've never seen before: |0| = λx. x |n+1| = λ_. |n| In other words, 0 is identity, and successor is the const function. This makes the predecessor function easy to define. Just apply Succ n to anything to get n back. The article fails to answer the most crucial question about these numerals though: Can we write a function that tests if a numeral represents 0? I.…
I'm pretty sure it's impossible to write a function that tests for zero for these numerals. Necessarily, any such function f(|n|) would have to expand at some point into a toplevel |n|(args...) with some number of args. This call must be toplevel, not as an argument to another function, because otherwise it is lazy and not executed. The number of args also cannot be infinite, since that would require an infinitely la…
> When n > numargs, |n|(args...) ignores all its arguments and halts
I would say it reduces to a term of the form \_. \_. M that is definitely different from both False and True.
Re: λ Calculus (2013) [pdf]
#60Shouldn't that be:
f(x) = x^2, f : Z → Z+
?