Last active
December 30, 2015 09:08
-
-
Save MuffinTheMan/7806903 to your computer and use it in GitHub Desktop.
Prolog predicate to get an element from a 2-dimensional list at some (Row, Column).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Get an element from a 2-dimensional list at (Row,Column) | |
% using 0-based indexing. | |
nth0_2(Row, Column, List, Element) :- | |
nth0(Row, List, SubList), | |
nth0(Column, SubList, Element). | |
% Example use: | |
% | |
% ?- nth0_2(2, 1, [[1,0], [2,9], [3,4]], El). | |
% El = 4. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment