The main thing you need is a predicate that calculates combinations of a given length and of a given list.
The main thing you need is a predicate that calculates combinations of a given length and of a given list: comb(0, _, ). Comb(N, X | T, X | Comb) :- N > 0, N1 is N - 1, comb(N1, T, Comb). Comb(N, _ | T, Comb) :- N > 0, comb(N, T, Comb).
Usage:? - comb(2, a, b, a, Comb). Comb = a, be ; Comb = a, a ; Comb = b, a ; false.(See more here.) Now you can just apply this predicate on your data: name(george, math, 20).
Name(steve, phys, 21). Name(jane, chem, 22). Name_list(L, N) :- findall(X, name(X, _, _), Xs), length(Xs, Len), between(0, Len, N), comb(N, Xs, L).
Usage examples:? - name_list(L, N). L = , N = 0 ; L = george, N = 1 ; L = steve, N = 1 ; L = jane, N = 1 ; L = george, steve, N = 2 ; L = george, jane, N = 2 ; L = steve, jane, N = 2 ; L = george, steve, jane, N = 3 ; false.?- name_list(george, steve, N).
N = 2 ; false.?- name_list(L, 2). L = george, steve ; L = george, jane ; L = steve, jane ; false.
Thank you. I think I must work on prolog. But I cannot do another thing.
If you help me, I would be very happy :)) – dark May 13 at 7:42 @dark If you like the answer vote it up, if you think it answers your question: mark it as the selected answer, if you have another question then create a new post asking it there. This is how Stackoverflow works... – Kaarel May 13 at 7:47 you are right :)) – dark May 13 at 7:54.
Name(george, math, 20). Name(steve, phys, 21). Name(jane, chem, 22).
Name_list(Name_List,N) :- integer(N), findall(Name,name(Name,_,_),L), combination(L,N,Name_List). Name_list(Name_List,N) :- var(N), findall(Name,name(Name,_,_),L), length(L,Len), for(1,N,Len), combination(L,N,Name_List). Combination(X,1,A) :- member(A,X).
Combination(A|Y,N,A|X) :- N > 1, M is N - 1, combination(Y,M,X). Combination(_|Y,N,A) :- N > 1, combination(Y,N,A).
Thank you very much :)) – dark May 13 at 7:41.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.