Prolog - 从拼图中删除元素

时间:2017-05-12 15:54:20

标签: prolog sudoku

所以我需要做一个从列表中删除元素的谓词。 有人能告诉我程序中的错误吗?

由于

puzzle_ref(Puz, (L, C), Cont) :-
    nth1(L,Puz,Linha),
    nth1(C,Linha,Cont).

puzzle_muda(Puz, (L,C), Cont, N_Puz) :-
    nth1(L,Puz,Linha),
    lista_muda(Linha,C,Cont, N_Linha),
    lista_muda(Puz,L,N_Linha, N_Puz),!.

lista_muda([_|T], 1, X, [X|T]) :- !.
lista_muda([H|T], I, X, [H|R]):-
    I > 0,
    NI is I-1,
    lista_muda(T, NI, X, R), !.
%lista_muda(L, _, _, L).

delT(_, [], []).
delT(X, [X|T], T).
delT(X, [Y|T], [Y|T1]) :-
    delT(X, T, T1).

tira_num_aux(_, [], _, []).
tira_num_aux(Num, Puz, Pos, N_Puz) :-
    puzzle_ref(Puz, Pos, Cont), 
    delT(Num, Cont, Removido),
    puzzle_muda(Puz, Pos, Removido, N_Puz).

0 个答案:

没有答案