[mercury-users] Equivalent of Prolog setof with free variable

Jeff Thompson jeff at thefirst.org
Wed Jan 25 05:19:50 AEDT 2012

Hello.  What is the preferred way in Mercury to implement the equivalent 
of setof with a free variable.  For example, Prolog:

person(bob, accounting).
person(alice, accounting).
person(fred, sales).

departmentMembers(Department, People) :-
   setof(Person, person(Person, Department), People).

Calling departmentMembers returns multiple times with results for the 
free variable:
Department = accounting,
People = [alice, bob] ;

Department = sales,
People = [fred].

What is the preferred way to get this in Mercury?

- Jeff

mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au

More information about the users mailing list