このディレクトリの索引

#  
#  % ?- variablize([a,b,c], X, L).
#  % L = [[X, b, c], [a, X, c], [a, b, X]]
#  Now I am trying to extend this predicate to accept a list of variables, example:
#  
#  % ?- variablize([a,b,c], [X,Y], L).
#  % L = [[X, Y, c], [X, b, Y], [a, X, Y]]
#  My code so far is:
#  
#  replace_at([_|Tail], X, 1, [X|Tail]).
#  replace_at([Head|Tail], X, N, [Head|R]) :- M is N - 1, replace_at(Tail, X, M, R).
#  
#  replace_each([], _, _, [], _).
#  replace_each([_|Next], Orig, X, [Res|L], N) :-
#      replace_at(Orig, X, N, Res),
#      M is N + 1,
#      replace_each(Next, Orig, X, L, M).
#  
#  variablize(I, X, L) :- replace_each(I, I, X, L, 1).
#  Any pointers? Do I extend replace_at/4 to have a list of indexes that should be skipped?
#  

variablize(L1,L2,L) :-
        append(L1,L2,L3),
        length(L1,Len1),
        length(L2,Len2),
        findall(L4,(
                    組合せ(L3,Len1,L4),
                    変数の個数(L4,Len2)),
                L).

変数の個数([],0).
変数の個数([V|R],N) :-
        var(V),
        変数の個数(R,N1),
        N is N1 + 1.
変数の個数([_|R],N) :-
        変数の個数(R,N).