Little problem please help
From: Magellan (magellano_at_poczta.fm)
Date: 06/18/04
- Next message: N.: "Re: Executing external programs in Prolog/Progol"
- Previous message: x: "Re: Counting propositions"
- Next in thread: Pento: "Re: Little problem please help"
- Reply: Pento: "Re: Little problem please help"
- Reply: Nick Wedd: "Re: Little problem please help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: N.: "Re: Executing external programs in Prolog/Progol"
- Previous message: x: "Re: Counting propositions"
- Next in thread: Pento: "Re: Little problem please help"
- Reply: Pento: "Re: Little problem please help"
- Reply: Nick Wedd: "Re: Little problem please help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|