このディレクトリの索引
#  When given a list I would like to compute all the possible combinations of pairs in the list.
#  
#  e.g 2) input is a list (a,b,c) I would like to obtain pairs (a,b) (a,c) (b,c)
#  
#  e.g 1) input is a list (a,b,c,d) I would like to obtain pairs (a,b) (a,c) (a,d) (b,c) (b,d) and (c,d)
#  

'I would like to obtain pairs in the list'(_input_list,_pairs) :-
        findall(_pair,(
                    combination(_input_list,2,_pair)),
                _pairs).

combination(L1,1,[A]) :-
        member(A,L1).
combination([A|R1],N,[A|R2]) :-
        N > 1,
        M is N - 1,
        combination(R1,M,R2).
combination([_|R1],N,R2) :-
        N > 1,
        combination(R1,N,R2).