Problem 2: Find It! (100 pts)
Implement the Scheme procedure find
, which takes a number n
and a list of numbers lst
. It returns the position (i.e. index) where n
appears in lst
. Assume that n
appears exactly once in lst
.
Note: Your solution should be tail-recursive.
(define (find n lst)
'YOUR-CODE-HERE
)
;;; Tests
; scm> (find 1 '(1 2 3))
; 0
; scm> (find 2 '(1 2 3))
; 1