Scheme Exercises
back to exercise list
previous next
Group: Exercise: 29/48
positionOf:
Find the position of the first occurrence of an element inside a list
(Difficult): Create the function "positionOf" which will be given an element and a list and will return the position of the first occurrence of the element inside the list. It will return 0 if the element is not found. For instance: (positionOf 'a '(a b c)) ; -> 1 (positionOf 'b '(a b c b)) ; -> 2 (remember: first occurrence) (positionOf 'c '(a b d)) ; -> 0
|