Usually a predicate is a function that takes one or more arguments and returns a boolean value indicating whether any statement about the arguments is true or false.
Examples of predicates in natural language can be “blue”, “longer than two meters”, “belongs to MC Hammer”, “is underground”.
When performing a search in any system - for example, in a file system, a database table, a graph - maybe the system itself provides certain built-in search queries (the file system may have a built-in search by file name; the chart may have a built-in search by distance from given node); or, for greater flexibility, there may be a search method by providing a custom predicate function.
Depending on the details, this custom predicate function can be passed as an expression tree or a pointer to some actual executable code or query expression that needs to be analyzed. All that is required is that the system has a way to call a predicate for each candidate element; and that the predicate returns true or false for each candidate element.
Search results are exactly those elements for which the user predicate returns true.
source share