Article View: comp.lang.prolog
Article #3894existential quantification in bagof and setof
From: Bob Riemenschneider
Date: Tue, 07 Feb 1989 20:57
Date: Tue, 07 Feb 1989 20:57
33 lines
1165 bytes
1165 bytes
=> E.g., given the DB
=>
=> foo(1,2,3,4).
=> foo(2,3,4,5).
=> foo(3,4,5,6).
=> foo(4,5,6,7).
=>
=> I can do
=>
=> | ?- T = p(X,Y,Z), setof(First, T^foo(First,X,Y,Z), Set).
=>
=> T = p(X,Y,Z),
=> X = _79,
=> Y = _94,
=> Z = _109,
=> First = _132,
=> Set = [1,2,3,4]
=>
=> I'd be curious to find out if other Prologs work like this.
I tried this in AAIS Prolog version M-1.15 on my Mac and got:
?- T = p(X,Y,Z), setof(First, T^foo(First,X,Y,Z), Set).
T = p(2,3,4),
X = 2, Y = 3, Z = 4, First = _4, Set = [1] ;
T = p(3,4,5),
X = 3, Y = 4, Z = 5, First = _4, Set = [2] ;
...
According to the AAIS manual, the "goal [VAR^GOAL] is equivalent
to just calling GOAL if the variable [VAR] is bound."
-- rar
Technical Details
Message-ID:
<8902072057.AA21884@deimos.ads.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!zodiac!DEIMOS.ADS.COM!rarShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!zodiac!DEIMOS.ADS.COM!rar From: rar@DEIMOS.ADS.COM (Bob Riemenschneider) Newsgroups: comp.lang.prolog Subject: existential quantification in bagof and setof Message-ID: <8902072057.AA21884@deimos.ads.com> Date: 7 Feb 89 20:57:03 GMT Sender: daemon@zodiac.UUCP Lines: 33