Right to the chase:
I'm having trouble dealing with Prolog's unification system, and what happens to wildcards when they go through my procedure. My code is as follows:
board(B) :- [R1, R2, R3, R4, R5, R6, R7, R8, R9] = B,
noDuplicatesRows([R1, R2, R3, R4, R5, R6, R7, R8, R9]),
horzAllWorthy([R1, R2, R3, R4, R5, R6, R7, R8, R9]),
vertAllWorthy([R1, R2, R3, R4, R5, R6, R7, R8, R9]).
The board is a sudoku board. I'm basically testing if the rows in the board have duplicate numbers, then testing to see if the rows and columns pass certain constraints. The problem is that the rows have wildcards in them to represent empty spots (laid out like: [ _ ,1,4,3_ .... etc]). From what I've gathered, when I run B through noDuplicatesRows, the wildcard spots are given values before they get run through the other two procedures, which is not what I want. However, due to Prolog's unification system, I can't seem to get around this (and I've already tried duplicating the list!).
Any answers here, or am I going about this in a very non-Prolog way?
edit: helper function code
noDuplicatesRows([]).
noDuplicatesRows([H|T]):- usedNumbersRow(H, X), diff(X), !, noDuplicatesRows(T).
usedNumbersRow([], []).
usedNumbersRow([X|Xs], R) :- var(X), validval(X), !, usedNumbersRow(Xs, R).
usedNumbersRow([X|Xs], [X|R]) :- usedNumbersRow(Xs, R).
diff([H]).
diff([H|T]):- not(member(H,T)), diff(T).