Subject: Re: [SWIPL] Basic Newby question

From: "Richard A. O'Keefe" <[email-masked]>
Date: Fri, 23 Mar 2001 12:38:37 +1200 (NZST)

Michael J Lew <[email-masked]> wrote:
	I can't seem to figure out how to for example - extract
	all the names of the happy people to a list, because there
	is no 'non member' function

There aren't any functions in Prolog, only predicates.

You don't *need* a non-member "function" because you have member/2
and \+ /1.  Y is not a member of Xs if \+member(Y, Xs).

FACTS	
	mood(bob,happy).
	mood(chirs,angry).
	mood(sally,happy).
	
QUERY
	find_mood(Mood,[Head|Tail])
	mood(Name,Mood),
	Head = [X|Head],
	find_mood(Mood,[Tail]).
	
I cannot make sense of this.

If you want to find the happy people, just do
	?- setof(Person, mood(Person,happy), HappyPeople).