Little problem please help

From: Magellan (magellano_at_poczta.fm)
Date: 06/18/04


Date: 18 Jun 2004 03:10:26 -0700

Hi
I write a small, Simple (for you i think it will be simple :-)
)programm,
There is a list of elements, one should it sum up ( the condition has
to be fulfilled sum > 10 ( for examle)) the and next condition which
has to be fulfilled is that the number of elements in subsets should
be < 5 ( 5 for example). Programm has to display all subsets of main
set, which these conditions fulfil, and I have problem here, I don't
know which function,which predycate I have to apply, to display all
results.

Programm looks like this:

rozmiar_zbioru([],0).
rozmiar_zbioru([_|O],L):-rozmiar_zbioru(O,L1),L is L1+1.

suma_elementow_w_zbiorze([],0).
suma_elementow_w_zbiorze([G|O],L):-suma_elementow_w_zbiorze(O,L1),L is
L1+G.

wyniki([],0).
wyniki([G|O],Y1,Y2):-suma_elementow_w_zbiorze([G|O],Y1),rozmiar_zbioru([G|O],Y2),Y1
> 5, Y2 < 10.

I try to receive all possible results by use something like this:

 Generate the combinations of k distinct objects
% chosen from the n elements of a list.

% combination(K,L,C) :- C is a list of K distinct elements
% chosen from the list L

combination(0,_,[]).
combination(K,L,[X|Xs]) :- K > 0,
   el(X,L,R), K1 is K-1, combination(K1,R,Xs).

but it isn't quite good.

I wil be greatful for any help.

Bye
Michael



Relevant Pages

  • error using reshape
    ... using reshape, the number of elements must not change" ... elements is quite long for large data sets and the sum ... Suppose tha the column's name is a. ... coming up if i type (after running the programm) in the CW ...
    (comp.soft-sys.matlab)
  • Re: Little problem please help
    ... > There is a list of elements, one should it sum up (the condition has ... > set, which these conditions fulfil, and I have problem here, I don't ... De wereld was soep, en het denken meestal een vork, ...
    (comp.lang.prolog)
  • Get every 10 sec a int.value and need to take the sum of the last 18 values
    ... i get every 10 sec a int.value and need to take the sum of the last 18 values. ... the programm should work permanently. ... Best regards ...
    (comp.lang.labview)