如何在PROLOG中访问规则数据

如何在PROLOG中访问规则数据,prolog,Prolog,我必须确定两个矩形是否重叠,我可以这样做,但我正在努力弄清楚如何获取给定的数据,并相互比较以确定更大的值 %This is :what would be happening : %separate(rectangle(0,10,10,0), rectangle(4,6,6,4)) separate(R1,R2) :- %I Have to figure out how to take the values from R1 and R2 and compare %them to

我必须确定两个矩形是否重叠,我可以这样做,但我正在努力弄清楚如何获取给定的数据,并相互比较以确定更大的值

%This is :what would be happening :
%separate(rectangle(0,10,10,0), rectangle(4,6,6,4))

separate(R1,R2) :-
    %I Have to figure out how to take the values from R1 and R2 and compare
    %them to one another.
.
这被称为“模式匹配”

在许多情况下,最好直接写:

separated(rectangle(A1, B1, C1, D1), rectangle(A2, B2, C2, D2)) :-
    /* now just use your As and Bs */
这被称为“模式匹配”

在许多情况下,最好直接写:

separated(rectangle(A1, B1, C1, D1), rectangle(A2, B2, C2, D2)) :-
    /* now just use your As and Bs */