문제

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).

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top