Re: [eclipse-clp-users] Counting

From: Philipp Marcus <marcus_at_...247...>
Date: Fri, 14 May 2010 09:49:09 +0200
Hi,

I would do it something like this:

solve(Count) :-
     Array = [](40,6,31,84,4),
     (    fromto(0,This,Next,Count),
          foreachelem(Elem,Array)
     do
         (Elem > 10 -> Next is This +1; Next = This)
     ).

Best regards,
Philipp

On 12.05.2010 11:26, peter barkly wrote:
> Hello,
>
> I am new to Eclipse.
>
> How do I count elements of a list/array that satisfy a particular 
> condition?
>
> For example, I want to count the number of elements in a list that are 
> larger than 10.
>
> solve(Count):-
>     dim(Array, [5]),
>     for(I, 1, 5) do
>     (
>       % get value of Count here
>     ).
>
>
>
> ------------------------------------------------------------------------------
>
>    
>
>
> _______________________________________________
> ECLiPSe-CLP-Users mailing list
> ECLiPSe-CLP-Users_at_lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users
>    
Received on Fri May 14 2010 - 07:49:12 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 16 2024 - 09:13:20 CEST