Instructor>Hello and welcome. In this lesson, you will learn about functional programming for advanced students. The important thing to know about functional programming is that FP uses functions rather than objects and classes, and functions are a set of code that follows a logical order for a given task. Now, there's a few concepts in functional programming, that's important to know. One being is that a function will return the exact same result every time it's called, as long as you use the same set of arguments, the same set of input data and parameters. So since functional programming is logic driven and follows a step-by-step process, it has to have a starting point. And that starting point is called the main function or in mobile app development for Android, it's called the main activity, and this is the entry point for our program. So in order to create a function, we have to have a kotlin keyword for that. And that's fun, f-u-n, fun for function. And we have to give the function a name. So here in this example, the name of the function is called onCreate, these letters and numbers and underscores and as good practice to use this camelCase convention. And whatever name we give it we want it to tie into the logic that we're actually doing in that function. So in this case, it's called onCreate. And that's a good name for this function because this function is going to invoke when the user creates the application by tapping on the icon. And then at that point, there's gonna be binding and controlling and other actions. So we want to provide a name as a kind of a way to give some indication of what the function actually does. And then we want to put the logic or the function in between these two curly braces, the opening curly brace, and the closing curly brace. And we can even override the function by giving it additional capability with a set of new instructions. And we can even give it super capability. And a function can accept input and it can return a result or output. And if we give it the same input, we're gonna get the same result. And when we change the input, we're going to get a different result. Okay, so I'm gonna show you an example of a function. So right here, I'm going to put in fun, and I'm going to call this function... What can we call it? I'm gonna call it kotlinstudent and I'm gonna put it in brackets, I'm gonna use the camelCase method. And I'm gonna put in curly braces and in between the curly braces, I'm gonna do a log. I'm gonna log.i and for the tag I'm going to say, student functional and for the message, I'm gonna say this is our functional programming lesson. All right, so this is our function. And now, to invoke the function all we have to do is call it. And we're gonna call it from the main activity. So I'm gonna do a simple call here by saying student and it brings up the name of my function, which is kotlinstudent, I'm gonna double click on that, and its ready to go. So lets run it, the gradle is building, emulator is up. The launch succeeded. Now lets search for our log. I believe we said it was student, and there it is. This is our tag, student functional and this is our message. This is our functional programming lesson. Okay so we have our function. Now lets run it three times in a row, by using a for loop. So I'll say for i in 1, lets do it 3 times. And I'm gonna give it curly braces, there we go. Lets run it. Gradle is building launch succeeded. And lets look for our tag. I say student. And good, it ran twice. Well the one and for the two, and then it stopped before the three. Good, that's what we want. So the big idea behind functional programming is that you're extracting functionality from your main program and you're putting it in a separate function or a separate set of code, which is similar to a program unto itself. And the reason you want to do that is so that you don't have to write this code many times. Now for the simple function that might not seem like a big deal, but when your functions become big and complex, then that becomes a very big deal. You don't wanna have to write this stuff over and over again. The great thing about functional programming is all you have to do is write your code one time, and then you can call it as many times as you want. So that is the foundation of functional programming, which is basically encapsulating a given set of functionality or given set of logic so that we can access it with a call. All right. So that concludes our lesson on functional programming for advanced students. Thanks for watching. Stay tuned for the next lesson. So let's go.