Hook
More breakout videos from this creator.
Twin, you gotta scratch the serial number off the blick before you slide. So boom, we got our blick and we wanna pull up and get to spraying. If we create a function called blick and it takes in mag, and we create a for loop to go through the whole mag, and make sure you go through the whole thing, because if you spin with me and I see you got something left, it's gonna be a problem. But we're gonna go through the whole list and subtract one from every spot. Now we can call the function and run the code, and you see when we run it, we dumped the whole mag. But if you don't want to get caught, you got to use a throwaway function. A lambda is an anonymous one line function used for quick operations. Think of it as a throwaway blick. You want to use the lambda when you need a short function for a one time task. Just like you don't need a bunch of throwaway blicks, you don't need a bunch of lambda functions. For the lambda syntax, it goes to the keyword lambda, then it goes to arguments, colon, then an expression. To make the throwaway blick, we're going to create a variable called blick and we're going to make it equal to list, then map. If we don't put list, then our output will look funny and it won't be a list. We use map to apply a function to every item in the list. So for our argument or our input, I'm going to put A, but you can name it whatever. For the expression, I'm going to do A minus one because we want to subtract one from every spot. And finally, we do comma mag so it works on our mag list. Now you see when we run it, the mag is empty and we didn't get caught.