Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prolog Quick question.

Status
Not open for further replies.

snaps11

Programmer
Joined
May 3, 2010
Messages
1
Location
US
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).
 
Did you test it on a list ?
 
It returns the N-element of the list.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top