このディレクトリの索引
#  I'm trying to figure out how to generate a list of sets, where each set has a length of N and the sum of each set is X.
#  
#  I found this code:
#  
#  num_split(0,[]).
#  num_split(N, [X | List]):-
#     between(1,N,X),
#     plus(X,Y,N),
#     num_split(Y,List).
#  And I can use that to get a list of sets with sum X:
#  
#  num_split(6,List),length(List,5).
#  List = [1, 1, 1, 1, 2] ;
#  List = [1, 1, 1, 2, 1] ;
#  List = [1, 1, 2, 1, 1] ;
#  List = [1, 2, 1, 1, 1] ;
#  List = [2, 1, 1, 1, 1] ;
#  false.
#  The problem is that those are all permutations, and I'm looking for combinations. The output I'm looking for should be something like get_combos(Sum,Length,List):
#  
#  get_combos(6,2,List).
#  List = [5,1];
#  List = [4,2];
#  List = [3,3];
#  false.
#  Any pointers?
#  

重複組み合わせの合計(_重複組み合わせの合計,_要素数,_重複組み合わせ) :-
        _出現する最大数 is _重複組み合わせの合計 - _要素数 + 1,
        findall(N,(
                    between(1,_出現する最大数,N)),
                _1から出現する最大数までのならび),
        重複組合せ(_1から出現する最大数までのならび,_要素数,_重複組み合わせ),
        sum(_重複組み合わせ,_重複組み合わせの合計).


%  重複組合せ/3