in.logic

来自「国外的一套开源CRM」· LOGIC 代码 · 共 42 行

LOGIC
42
字号
/* 
Demonstrates the necessary indirection for transitive rules, like in done through within.

Try the query:
    leaf(L)
which should produce the result:
    L = englewood
    L = fortCollins
    L = westbrook
    L = yarmouth
    L = austin
    L = menzingen
    L = lexington
    L = richmond
    no more results

Try the query:
    within(X, "switzerland")
which should produce the result:
    X = zug
    X = menzingen
    no more results
*/
in("englewood", "colorado");  
in("fortCollins", "colorado");
in("westbrook", "maine");
in("yarmouth", "maine");
in("austin", "texas");
in("menzingen", "zug");
in("lexington", "kentucky");
in("richmond", "virginia");
in("colorado", "us");
in("maine", "us");
in("texas", "us");
in("zug", "switzerland"); 
in("kentucky", "us");
in("virginia", "us"); 

within(X, Y) :- in(X, Y);
within(X, Y) :- in(X, Z), within(Z, Y);
leaf(X) :- in(X, _), not in(_, X);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?