Loading lesson…
Level 1 · Apprentice0 XP
Functions that take functions: the idea behind most of the Kotlin standard library.
Step 1 / 5
ProblemLoop over a list, test each element, collect the ones that pass. Then the same loop with a different test. Then again. The loop is identical each time. Only the test changes.
← → step
Before this: Classes, properties and objects
🛠️ Your turn
Reading is not the skill, doing is. Try for ten minutes before you open the hint. Getting stuck first is what makes the solution stick.
1.Write your own versions of two standard functions as extensions on List<T>: myMap(transform) and myFirstOrNull(test). Then write inline fun measure(block) that returns a Pair of the block's result and the time it took.