This course has been updated! We now recommend you take the Hardcore Functional Programming in JavaScript, v2 course.
Transcript from the "Point-Free" Lesson
[00:00:00]
>> [MUSIC]
[00:00:04]
>> Joe Nelson: Well, one example of Point Free. It takes it a sec for the arrow keys to work. Is this has points. The point, points mean arguments. So I don't know why they call it Point Free. Maybe in the analogy of when I was saying, functions viewed as nouns or whatever just take points to points.
[00:00:24] Maybe that's what it was. Or maybe, it's something like, hm, I don't know. But you could think of, Point Free means argument free. Making a new function without having to say function taking argument x, y, z. Or in this case, taking the function error.
>> Joe Nelson: Let me find-
[00:00:46]
>> Speaker 2: All right, that's good.
>> Joe Nelson: I mean these are all Point Free. This has infinity. That's still, I'd have to declare a function.
>> Speaker 2: Yeah, it's really like the data that's going in, like that list is your point, you know?
>> Joe Nelson: I was looking for, there was another one with the error.
[00:01:09]
>> Joe Nelson: Oops. No, no, no, don't look at that. Okay, here we go. So this is that same one without the point. So it used to be on our call of function that takes a point, an argument named error and it passes it in. And instead of having to make a function that takes a named argument, we can substitute that with a composition which creates a function.
[00:01:31] It just doesn't have a name. And then the argument doesn't have a name. We didn't mention the argument. So if I, I think it's four. No, don't look at that again. The slides are in an awkward order, but we could code it in the JS bin. But the point is, you know you're Point Free when you're not saying function, and then naming arguments and then using those arguments inside the function.
[00:01:57] When you have a palette of tools, like compose that you can put other stuff together with. So you make a couple basic functions like deep down at the bedrock, often in a library like and you could just push them together and not name it when you're doing it.
[00:02:12] Or like in our average thing, when I said fork, I didn't use any variables there. Let's see, go back. Let's look at that. This is totally Point Free. So check it out, fork. I define a thing called average. And there are no variables. I just say it's divide sum size fork.
[00:02:34] It's like snapping Legos together. So that's how I'd just define Point Free, and know when you're using it.
>> Speaker 3: What's confusing about that is it looks like you're passing three arguments in four. I mean, ultimately you are, right?
>> Joe Nelson: Passing, really you are, yeah.
>> Joe Nelson: I see. Just the fact that we're also doing the currying on top of the composition?
[00:03:00] Because four takes, four up here, but we only gave it three down there. Is that the confusing part?
>> Speaker 3: No, just, you say that if, I understand what fork is doing. I don't know that I have enough depth of understanding to articulate what I found confusion on.
>> Speaker 4: You're confused about your confusion.
[00:03:21]
>> Speaker 3: Yeah.
>> Joe Nelson: Deep confusion.
>> Speaker 5: Jessie W wants to clear, yeah, I think I might-
>> Joe Nelson: Yeah, fork isn't Point Free. Average was built in a Point Free way. Yeah, fork totally, here's the points. Lastly, FG.
>> Speaker 3: I think that's what I was trying to say.
>> Joe Nelson: Yeah, yeah, if I was saying fork was, I was being sloppy.
[00:03:40] Fork is not.
>> Speaker 2: And since you have another minute or two, it might be fun to just define, just do two stupid composes to kinda show, like maybe do the phone number thing where we the dashes for, you can make a replace helper that's just curried. Then replace the dashes for the slashes or something, and-
[00:04:05]
>> Joe Nelson: Let's see.
>> Speaker 2: I don't know, maybe you shouldn't. I don't know. How much lecture do you have left? [LAUGH]
>> Joe Nelson: I got a couple slides. Maybe would check out the slides and see what kind of time we have and how hungry we are and, yeah.