There is a fundamental difference between C-style function pointers vs. delegates or function objects. Pure function pointers cannot hold any state other than the function itself. In contrast, delegates and function objects do store additional state that the function can use.
Given a list of numbers, you can use such a method to find all numbers in the list that are greater than a local variable
x. However, in order to do that, the predicate have access to
x. In subsequent posts, I’ll explore how this can be done in different languages.