Scheme Exercises

back to exercise list       previous     next

Group: Challenging recursions    Exercise: 4/6 

lastPositionOf:  Find the position of the last occurrence of an element inside a list

(quite difficult): Create the function lastPositionOf which will be given an element and a list, and will return the position of the last occurrence of the element inside the list. It will return 0 if the element is not found.
NOTE: YOU ARE ALLOWED TO CREATE NO MORE THAN ONE HELPER FUNCTION!
(lastPositionOf 'a '(a b a)) ; -> 3
(lastPositionOf 'a '(b c d)) ; -> 0