29 ms·
Cool article, BUT! it leaves so many terms unexplained: - What's the distinction between a "parameter`, a "variable", and an "argument"? - What is "body" as i
by ewuhic 2y ago
Cool article, BUT! it leaves so many terms unexplained:
- What's the distinction between a "parameter`, a "variable", and an "argument"?
- What is "body" as in "Body M"?
- What's a "bound" variable?
- What exactly is a "function call"?
- In "... a value that is mapped to itself by the function.", what do "mapped to itself", and, more specifically, "mapped" mean?
Would appreciate the answers!
- seanhunter 2y agoI'll take one of these. > In "... a value that is mapped to itself by the function.", what do "mapped to itself", and, more specifically, "mapped" mean? A mathematical function is something more general than a function in programming. In maths, a function consists of two sets known as the domain and codomain and a rule which "maps" things in the domain into the associated things in the codomain[1]. You can think about the domain as all the possible inputs to the function and the codomain being a set which at least contains all the possible outputs from the function. So say the rule of my function is f(x) = sin(x) and for simplicity I say the domain is real numbers greater than or equal to zero but less than 2pi, then the function "maps" any value in that domain to a value in its codomain (which in this case will be real numbers from -1 to 1). And what it's actually doing when it maps a number is it applies "sin" to that number to find the value in the codomain (which in computer science we would call the return value of the function). So when the author talks about fixed points being values which are mapped onto themselves by the function they are values in the domain where you apply the rule of the function and you get back the same value. So for f(x) = sin(x), 0 would be such a value because sin(0) = 0. Say my function is f(x) = x^3, then 0, 1 and -1 are fixed points, because f(-1) = (-1)^3 = -1, and you can see the same applies to f(0) and f(1). As a bonus, if my rule is f(x) = sin(x), then "x" is a "parameter" or "argument" to the function, because it is the name I give to a value that is passed into the rule of my function. It is also a variable because it's a name for a thing which varies but not all variables get used as parameters to functions. For example if I write y = f(x), then y is a variable which is not any kind of parameter for example. Hope that helps. [1] I suppose technically into the "image set" of the function, which is a subset of the codomain comprising the actual output values of the function only.
- seanhunter 2y agoAs a slight additional aside I realised it might be interesting for some to understand some parallels between functions in programming and functions in maths. For programmers, you can think of the rule of the function as being like the function body when you write a function in a computer program. The codomain is like the return type of the function (except in maths you're really talking about a set and in maths a set and a type are somewhat different things). The domain is like the type of the function inputs (although it's also a set not a type). So if you have a function where the rule is f(x) = x^2 you can hopefully see that if the domain is the real numbers that's a different function from if the domain is the complex numbers. I mentioned the image set of the function in my previous post, so just to finish off the explanation, say we have f where the domain and codomain are the reals and the rule of f is f(x) = x^2. The image set of f is actually going to be all the real numbers greater than or equal to zero (even though the codomain is all real numbers). The reason for this is if you (hypothetically) went through every value in the domain and applied the rule you would always get a value from zero to positive infinity. None of the real numbers when mapped by the function (squared) will return a negative number. The domain is the type of all the inputs, so if you have a function which takes multiple inputs, the domain will be a set of tuples (think of them like coordinates) and likewise for functions which have multiple outputs, the co-domain and image set will contain tuples.
- photochemsyn 2y agoThis explains the basic structure and definition of terms pretty well, i.e. body, variable, expression, head etc. Has links to more comprehensive coverage: https://palmstroem.blogspot.com/2012/05/lambda-calculus-for-absolute-dummies.html https://palmstroem.blogspot.com/2012/05/lambda-calculus-for-... Shows how to implement counting, addition, multiplication in Python: https://www.youtube.com/watch?v=9pmI-KK4dIA https://www.youtube.com/watch?v=9pmI-KK4dIA
- moi2388 2y agoMy other comment links to a YouTube series explaining these concepts very clearly, in case you’re interested