Yellowsgg
Yellowsgg

Reputation: 103

Prolog Unit Tests for Non-deterministic predicates

I am trying to use the Prolog Unit Tests from http://www.swi-prolog.org/pldoc/doc_for?object=section%28%27packages/plunit.html%27%29 It gives an example for non-deterministic predicates as

test(member, all(X == [a,b,c])) :-
    member(X, [a,b,c]).

I think it just tests for all element from the list X == [a,b,c], test if it is in the list [a,b,c]. But why does

test(member, all(X == [a,b,c])) :-
    member(X, [a,b,c,d]).

reports wrong "all" answer:?

Upvotes: 0

Views: 104

Answers (1)

Paulo Moura
Paulo Moura

Reputation: 18663

You want instead:

test(member, set(X == [a,b,c])) :-
    member(X, [a,b,c,d]).

Upvotes: 2

Related Questions