Learn how there are other higher order functions like drop, split, first, and more. They take closures and return a value or collection of values. The closure is the logic. Again, it's important to understand the needs and requirements you're trying to solve. Once you determine that, you can choose the best functions.
- [Instructor] Now we're going to talk about a few other…higher order functions that may not need as much attention.…First, we're going to talk about First.…So First returns the first item to match your criteria.…So let's say we want to look for the first item…that is longer than four characters.…I'm sorry if that's a boring example.…I know it,…but I'm trying to focus on the concept…and not get too muddled down…in the actual functionality of it.…I'll let you apply it to more complicated examples.…
So, let's say we'll call our result,…Let FirstLongName equal names.first,…and you have this where clause, more or less.…It takes a string and returns a bool.…The first thing that passes is going to return True…and that's where it stops.…So it takes a name.…I'll call it Val1 and it returns a bool…and I'll just return Val1.count, greater than four.…So the first one that's greater than four…will be assigned to FirstLong…and I'll print that out.…
So now when I run it,…it should print out an Optional Jenna,…'cause it may not actually find one that long.…
- What are closures?
- Closures and function types
- Basic higher-order functions, including sort and forEach
- Powerful higher-order functions, including map and reduce
- Passing functions
- Closure optimizations
- Higher-order functions on sets, dictionaries, and strings