 
Summary: Program #6 20 points
Prolog Programming
Don't show your code to anyone in the class. Don't read anyone else's code. Do not
google to find complete solutions to the exercises (as that involves reading someone else's
code). Don't discuss the details of your code with anyone except the tutors, grader, or your
instructor.
A list is either empty or it is composed of a first element (head) and a tail, which is a list
itself. In Prolog we represent the empty list by the atom [] and a nonempty list by a term [HT]
where H denotes the head and T denotes the tail.
1. (2 points) Find the last element of a list.
Example:
? my_last(X,[a,b,c,d]).
X = d
2. (2 points) Find the K'th element of a list.
The first element in the list is number 1.
Example:
? element_at(X,[a,b,c,d,e],3).
