Reification of term equality/inequality

前端 未结 6 1710
天涯浪人
天涯浪人 2020-11-22 16:45

Pure Prolog programs that distinguish between the equality and inequality of terms in a clean manner suffer from execution inefficiencies ; even when all terms of relevance

6条回答
  •  再見小時候
    2020-11-22 17:29

    It seems to be best to call this predicate with the same arguments (=)/3. In this manner, conditions like if_/3 are now much more readable. And to use rather the suffix _t in place of _truth:

    memberd_t(_X, [], false).
    memberd_t(X, [Y|Ys], Truth) :-
       if_( X = Y, Truth=true, memberd_t(X, Ys, Truth) ).
    

    Which used to be:

    memberd_truth(_X, [], false).
    memberd_truth(X, [Y|Ys], Truth) :-
       if_( equal_truth(X, Y), Truth=true, memberd_truth(X, Ys, Truth) ).
    

提交回复
热议问题