Prolog quick question
Explain what the following Prolog code does. Assume the third parameter is the result.
a( 1, [Hd | _Tl], Hd ).
a( N, [_ | Tl], Elem ) :-
N > 1,
N1 is N - 1,
a( N1, Tl, Elem).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.