We will now use what we have learned to implement a valuable language construction that is not built into R: list comprehension. List comprehensions provide a syntax for mapping and filtering sequences. In R we would use functions such as Map or Filter, or the purrr alternatives, for this, but in languages such as Haskell or Python, there is syntactic sugar to make combinations of mapping and filtering easier to program.
Take an algorithm such as quicksort. Here, the idea is to sort a list by picking a random element in it, called the pivot , splitting the data ...