SWI-Prolog Matrix. How to find the value of an element by indexes? -


map(1,    [[1,_,_,_,_,_,_,_,_,_],     [1,1,_,_,1,1,_,_,_,_],     [_,1,_,_,1,_,_,_,_,_],     [_,_,_,_,_,_,_,_,_,_],     [_,_,1,_,_,_,1,_,_,_],     [_,1,1,_,_,_,_,_,_,_],     [_,_,_,_,_,_,_,1,1,_],     [_,_,_,_,_,_,_,_,_,_],     [_,_,_,_,_,_,_,_,_,_],     [_,_,_,_,_,_,_,_,_,_]]). 

this matrix. how can find value of element second row , first column?. have no idea how can it. can me?

thank much!

you can write 4 argument predicate, at/4

at(mat, row, col, val) :- nth1(row, mat, arow), nth1(col, arow, val). 

and call like

test :- map(_, map), at(map, 2, 1, val), write(val). 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -