I'm working on a predicate to generate a list of values from rules. I have these rules:
casilla(1,4,1,1,3).
casilla(1,4,1,2,1).
casilla(1,4,1,3,2).
casilla(1,4,1,4,4).
casilla(1,4,2,1,0).
casilla(1,4,2,2,4).
casilla(1,4,2,3,0).
casilla(1,4,2,4,0).
casilla(1,4,3,1,1).
casilla(1,4,3,2,0).
casilla(1,4,3,3,0).
casilla(1,4,3,4,2).
casilla(1,4,4,1,4).
casilla(1,4,4,2,2).
casilla(1,4,4,3,3).
casilla(1,4,4,4,1).
and I need to save the last value of each rule in a list, for example:
BOARD = [3, 1, 2, 4, 0, 4, 0, 0, 1, 0, 0, 2, 4, 2, 3, 1].
I try to recursively save every element of this form:
createBoard2(N, M, Difficulty, [VALUE]) :-
casilla(Difficulty,N,_,_,VALUE).
createBoard2(N, M, Difficulty, [VALUE,T]) :-
casilla(Difficulty,N,_,_,X),
createBoard2(N, M, Difficulty,T).
but really I do not understand the error,I only returns the first VALUE thanks.
[VALUE,T]should be[VALUE|T]. - Paulo Moura