Being a hobbyist coder, I'm lacking some fundamental knowledge. For the last couple days I've been reading some stuff and the word "predicate" keeps reappearing. I'd very much appreciate an explanation on the subject.
Being a hobbyist coder, I'm lacking some fundamental knowledge. For the last couple days I've been reading some stuff and the word "predicate" keeps reappearing. I'd very much appreciate an explanation on the subject.
From C++ Primer 5th (§10.3.1):
A predicate is an expression that can be called and that returns a value that can be used as a condition.
Also from chapter Defined Terms section:
predicate : Function that returns a type that can be converted to
bool.
The best S.O. answer around predicates, that I have found, is on a duplicate question.
To summarize, in natural languages a predicate is the part of the sentence that describes a subject.
Jane is tall
Jane is the subject and is tall is the predicate.
In computer science we are not interested in asserting a fact about a subject but rather testing if something is true or false.
jane.isTall();
Here jane is some object with a predicate method that will return either true or false.