Re: count of result sets
- From: "Pierpaolo BERNARDI" <pierpaolo@xxxxxxxxxxxxx>
- Date: 25 May 2006 04:07:36 +0200
On Wed, 24 May 2006 17:52:50 +0200, Marten Lehmann <lehmannmapson@xxxxxx> wrote:
Hello,
lets say I have to following facts:
(* name, type of my small zoo *)
animal(river, dog);
animal(bouncy, mouse);
animal(spring, mouse);
How can I count the occurences of a certain criteria and use them in
another condition? e.g. "Which animal-types do I have in my small zoo,
that exists more or equal to two times?" With the given facts, "mouse"
should be returned.
====
animal(river, dog).
animal(bouncy, mouse).
animal(spring, mouse).
animal_at_least(N,AnimalType) :-
setof(Name,animal(Name,AnimalType),L),
length(L,LL),
LL >= N.
====
?- animal_at_least(2,A).
A = mouse ;
No
P.
--
Anything below this line is being added by the newsserver
Inviato da X-Privat.Org - Registrazione gratuita http://www.x-privat.org/join.php
.
- References:
- count of result sets
- From: Marten Lehmann
- count of result sets
- Prev by Date: Re: String is not string in SWI prolog , part/2.
- Next by Date: Re: How to replace a term to the inside of an other term?
- Previous by thread: count of result sets
- Index(es):
Relevant Pages
|
|