This is a procedure to return the last item in a list 1:
proc last (1)
if (isEmpty(1))
error('Oops. Empty list in procedure last.')
elseif (is empty(rest1))
return (first(1)
else return last(rest(1))
Modify that to create a recursive procedure getItem(i,l) that returns item i in a list 1, where i is an integer greater than zero.
proc getItem(i,1)
if (isEmpty(1))
error('Opps. Empty list in procedure last.')
else if (isEmpty(getItem,i1)
else if i > 0
return item(i,1)
is that correct?