Today’s mission was completing both sections of the Udemy class on functions. I’ve encountered functions in python before, but to my amazement I learned two wickedly awesome and mindblowing concepts:
The concept of anonymous functions is boss . One thing that confused me though, and I’ve yet to completely understand. Check this out:
In the section about higher order functions (aka functions that act on other functions), they introduced the reduce function via this example. Now the concept is pretty cool- using this higher order function, you’re able to assign a function to the list data structure, apply each of the list indicies as arguments in the sum function, and return the sum of all the numbers in the range. What I don’t quite understand is how it works with a function that has more than one argument. Does the reduce function somehow know how to properly iterate through the list? How is it keeping up with the list indicies that have been passed to the sum function? Not exactly sure yet, but functions that can ‘act’ on other functions is awesome. I think I grew pythonic legs today as opposed to any other day so far during my challenge.