From vannoord@let.rug.nl  Tue Mar 21 14:15:33 2000
Received: from gudrun.let.rug.nl (root@gudrun.let.rug.nl [129.125.8.21])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id OAA13681
	for <prolog@swi.psy.uva.nl>; Tue, 21 Mar 2000 14:15:32 +0100 (MET)
Received: (from vannoord@localhost)
	by gudrun.let.rug.nl (8.9.3/8.9.3) id OAA14516;
	Tue, 21 Mar 2000 14:15:38 +0100
From: "Noord G.J.M. van" <vannoord@let.rug.nl>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <14551.30202.324076.166772@gudrun.let.rug.nl>
Date: Tue, 21 Mar 2000 14:15:38 +0100 (MET)
To: Waseem Besada <waseem@isk.kth.se>
Cc: prolog@swi.psy.uva.nl
Subject: setof
In-Reply-To: <38D76853.F569780F@isk.kth.se>
References: <38D76853.F569780F@isk.kth.se>
X-Mailer: VM 6.72 under 21.1 (patch 7) "Biscayne" XEmacs Lucid

Waseem Besada writes:
 > 
 > Hi,
 > 
 > Why ?-setof(X,course(_,_,X),L). does not give a sorted list L of teachx
 > from the following facts.
 > 
 > course(java,time(monday,10,12),name(teach1)).
 > course(prog, time(friday,13,15), name(teach2)).
 > course(math, time(thrusday,8,10), name(teach3)).
 > course(c,time(wednesday,13,15), name(teach2)).
 > course(prolog, time(friday,10,12), name(teach4)).
 > 

use setof(X,Y^Z^course(Y,Z,X),L).

here, Y^Z^ existenially bind the Y and Z variables.

In  most cases, the following is more efficient, and quite likely
good enough:

findall(X,course(_,_,X),L0), sort(L0,L).


Gj


-- 
Gertjan van Noord Alfa-informatica, RUG,  Postbus 716, 9700 AS Groningen
vannoord at let dot rug dot nl            http://www.let.rug.nl/~vannoord/

