谓词...或其他术语?
只是出于好奇:如果我有一个类运算符(或函数等)接受多个参数(通常为 1 或 2)并返回 3 个值中的 1 个(而不是布尔 true 或 false),那么它是否仍然应该被称为谓词?还是模糊逻辑的特例?或者什么?
示例:模板
类 BinaryPredicate {
公众:
virtual int operator()(const T&lhs, const T&rhs) const = 0;
};
根据定义的继承运算符函数返回 -1、0 或 1(例如确定顺序)。
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).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯,您从函数中返回具体值,并且它们中没有任何模糊之处,您更多地处于三值逻辑域(有时称为三价)而不是模糊域中。例如,三价在电子(三态逻辑)中非常流行。器件可以处于 3 种状态:逻辑一(真)、逻辑零(假)和高阻抗。
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.