简体   繁体   中英

Prolog beginner, member/2 builtin predicate

I have this:

someuserdef(a,[b,c,d]).

When I try

?- someuserdef(a,L),member(b,L).

I don't get a true or false answer but the list

L=[b,c,d] ;
false.

How do I get just a true or false answer?

You're asking Prolog to give you a value of L that matches both rules. If it can tell that there's only one answer, it will return yes - otherwise it will give you the first answer, return no , and prompt you before checking for any more answers.

When you're providing variables (capital letters) to Prolog queries, it will return matches - it's when you ask it to check rules (with no variables) eg someuserdef(b, [b, c, d]) that it will return yes or no to indicate whether your assertion is true or false.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM