Created
December 11, 2012 08:36
-
-
Save trietptm/4257005 to your computer and use it in GitHub Desktop.
Find the K'th element of a list. The first element in the list is number 1.
This file contains 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
kth_element_of_list(X, [X|T], 1). | |
kth_element_of_list(X, [H|T], K) :- kth_element_of_list(X, T, K1), K is K1+1, K>1. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment