UNB/ CS/ David Bremner/ teaching/ cs2613/ tests/ T4/ sample/ samplesol/ find-recursive.rkt
#lang htdp/isl+
(define (find-helper lst index)
  (cond
    [(empty? lst) lst]
    [(zero? (first lst)) (find-helper (rest lst) (add1 index))]
    [else (cons index (find-helper (rest lst) (add1 index)))]))
    
(define (find lst)
  (find-helper lst 0))

(check-expect (find '()) '())
(check-expect (find '(0)) '())
(check-expect (find '(1)) '(0))
(check-expect (find '(1 2 0 3)) '(0 1 3))
(check-expect (find (build-list 10 (lambda (x) (modulo x 3)))) '(1 2 4 5 7 8))