<> 在序言中是什么意思?

时间:2021-02-08 08:14:36

标签: prolog turbo-prolog

示例:

PREDICATES
nondeterm likes (symbol,symbol)

CLAUSES
likes (ali,football).
likes (ali,tenis).
likes (ahmad,tenis).
likes (ahmad,handball).
likes (samir,handball).
likes (samir,swimming).
likes (khaled,horseriding).

GOAL
%
likes (Person, G1), likes (Person,G2), G1<>G2.

1 个答案:

答案 0 :(得分:3)

在该示例中,<> 表示“不相等”。查询:

likes(Person, G1),
likes(Person, G2),
G1 <> G2.

旨在找到一个喜欢两件事的 Person。如果没有 <>G1G2 可以彼此相等,并且查询可以找到只喜欢一件事的 Person

<> 可能特定于 Visual Prolog。在其他 Prolog 环境中,您可以改用 \=\==