Reputation: 564
map(1,
[[1,_,_,_,_,_,_,_,_,_],
[1,1,_,_,1,1,_,_,_,_],
[_,1,_,_,1,_,_,_,_,_],
[_,_,_,_,_,_,_,_,_,_],
[_,_,1,_,_,_,1,_,_,_],
[_,1,1,_,_,_,_,_,_,_],
[_,_,_,_,_,_,_,1,1,_],
[_,_,_,_,_,_,_,_,_,_],
[_,_,_,_,_,_,_,_,_,_],
[_,_,_,_,_,_,_,_,_,_]]).
This is my matrix. How can I find the value of the element from second row and first column?. I have no idea how i can do it. Who can help me?
Thank you very much!
Upvotes: 2
Views: 1085
Reputation: 60034
you can write a 4 argument predicate, at/4
at(Mat, Row, Col, Val) :- nth1(Row, Mat, ARow), nth1(Col, ARow, Val).
and call it like
test :- map(_, Map), at(Map, 2, 1, Val), write(Val).
Upvotes: 2