![]() This prints out 30 because the y you define on line 1 isn’t the same thing as the y in the function definition on line 2. Going back to JavaScript this is like how the following program: What does this become? At first glance it looks like it might become:īut that’s not right because the two different variables named z have different scopes in other words, they were defined in two different places. In this case, the function returns 20.Īpplying functions in the lambda calculus works exactly the same way! You just eat an argument and substitute it into the body of the function. What happens when this code is run? It runs the body of the function with the argument x replaced by 10 everywhere. Instead, let’s consider the following JavaScript expression: If the only thing in the language are functions then the only thing you could possibly do with these functions is call them! The fact that everything is a function in the lambda calculus can make it look more complicated than it is. Okay! So we’ve completely described how you write down lambda calculus programs, but how do you run them? In our previous example, x is a use of the variable x we’ve set aside in the declaration: ![]() The body of this function reads as “apply f to the result of applying x to x“.įinally, you use a variable just by writing the variable. So up above we have a part of a function that reads as: The lambda symbol signifies “hey, we’re starting to define a function”, by x we mean any letter, which is going to be the argument to the function, and the l means the body of the function.Īpplying a function just means you write two (or more) things next to each other. We can break the syntax of the lambda calculus into three pieces, then: The lambda calculus, on the other hand, is only its anonymous functions. Now JavaScript and Python have other programming constructs and data in their programming language. Notice the literal word lambda in the Python example? Yeah, that’s a reference to the lambda calculus! In Python, they look like lambda x: x * 3. If you’ve tried Python or JavaScript you may have seen anonymous functions before. This means you’re going to have to think really differently about what things like numbers mean. Everything is a function in the lambda calculus. Now, you’re probably looking at those and thinking “how are these numbers or if-statements or loops?” well they key to the lambda calculus is that it’s super-minimalist. ![]() What’s it actually look like? Well here’s how you write the numbers 0 through 3 in the lambda calculus:Īnd here’s an if-else-statement in the lambda calculus:Īnd here’s how you write a while-loop, call the Y-combinator! It’s a programming language, though a special one that was meant to be calculated by hand instead! ![]() In other words, it’s a language for programs you can write down that can be executed to calculate a number. It’s a kind of “algebra” of computation, where each expression you could write down in the lambda calculus executes to perform a complex calculation. That may be surprising, but even though computers didn’t yet exist, the idea of a machine that could do math had been around since the early 1800s when people like Ada Lovelace wrote the first algorithm for a very hypothetical computer called the Analytical Engine.Ĭhurch, on the other hand, tried to answer the question of the limits of computers by inventing a symbolic system, the lambda calculus, for doing calculations. You see, Turing came up with what we now call “Turing machines” as a way of figuring out what you could do with a machine that calculates. You may not have heard of Church before, but you’ve probably heard of one of the students that worked for him: Alan Turing! There’s a neat connection here between Turing’s work and Church’s lambda calculus. It was invented by Alonzo Church, a mathematician, in the 1930s. The lambda calculus is old old enough that it predates computers. Now, we’re going to talk about a programming language completely unlike everything else we’ve seen but one that’s still exerting influence today: the lambda calculus. There’s so many and most of them are really different from one another! We’ve covered a lot of really interesting ones so far: languages that treat pictures as programs, languages designed to run on mobile devices, languages designed to do computing fast, and many others. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |