I'm trying to become more familiar with recursion in Scheme. I have searched the question bank and see many "built-in" functions for finding duplicate entries in a scheme list, but am trying to design my own. I have not learned about "lambda" yet either. My concern is when I call the recursion function, the car element will be updated. I wish to keep it the same, but pass a new cdr each time, so the original car element can be compared against each subsequent element in the list. I want to return a #t if there is a match, and #f if there is no match or the cdr is empty (base case). Any help/advice would be greatly appreciated.
(define (findDuplicates list)
(if (null? list)
#f
(if (null? (cdr list))
#f
(if (= (car list) (getCarOfCdr list))
#t
(findDuplicates (cdr list)) //trying to use recursion
)
)
)
)
(define (getCarOfCdr list) //Helper function
(car (cdr list))
)