How do I find the index of an element in a list in Racket?
This is trivial implement of course, but I feel there is certainly something built in to Racket that does this. Am I correct in that intuition, and if so, what is function? Strangely, there isn't a built-in procedure in Racket for finding the 0-based index of an element in a list (the opposite procedure does exist, it's called list-ref ). However, it's not hard to implement efficiently: (define (index-of lst ele) (let loop ((lst lst) (idx 0)) (cond ((empty? lst) #f) ((equal? (first lst) ele) idx) (else (loop (rest lst) (add1 idx)))))) But there is a similar procedure in srfi/1 , it's called