Frage

Just out of curiosity: if I have a class operator (or function or the like) that accepts several arguments (normally 1 or 2) and returns 1 of 3 values (instead of boolean true or false) should it still be called a predicate? Or a special case of fuzzy logic? Or what?

Example:
template <class T>
class BinaryPredicate {
public:
virtual int operator()(const T& lhs, const T& rhs) const = 0;
};

which returns -1, 0 or 1 according to a defined inherited operator function (for example to determine order).

War es hilfreich?

Lösung

Hm, you are returning concrete values from your function, and there is nothing fuzzy in them, you are more in three-valued logic domain (sometimes called trivalent) than in fuzzy domain. For example, trivalent is very popular in electronic(three state logic). Device can be in 3 states: Logical one (true), logical zero(false) and high impedance.

Andere Tipps

Predicate suggests that you're affirming the truth of something - which suggests a true and false result, and only a true and false result.

In this case, I would personally call this a "Comparison", as it's really returning the result typically used for comparison operations - negative, zero, or positive.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top