You'll need to write a function that traverses the list of lists and generates a single list containing indices as the result. The result in your example would be something like [[0, 0], [0, 1], ...]
.
To do that, you'll need to split the function between two operations - one that traverses a single row (nested list) and another one that processes the outer list (containing lists as rows). The nested function for processing [1, 0, 0]
would look like this (note that it needs to take the index of the row from the outer function, so that it can generate the x, y coordinates):
% Processes single row of the data. Parameters:
% row (in), row index (in), current element index (in), result (out)
processRow([], _, _, []).
processRow([1|Xs], R, N, Rest) :- processRow(Xs, R, N+1, Rest)
processRow([0|Xs], R, N, [[R, N]|Rest]) :- processRow(Xs, R, N+1, Rest)
The second function would look roughly like this:
% Parameters:
% list of lists (input), current index (input), collected indices (output)
processOuter([], _, []).
processOuter([Row|Rows], N, [Res|Remaining]) :-
processRow(Row, N, 0, Res),
processOuter(Rows, N+1, Remaining).
I didn't try the code, so you may need to do a few minor corrections, but it should give you the general idea how the implementation might look like.