UNB/ CS/ David Bremner/ teaching/ cs2613/ tests/ T4/ sample/ samplesol/ find.rkt
#lang htdp/isl+
(define (find lst)
  (map first
   (filter
    (lambda (pair)
      (not (zero? (second pair))))
    (map (lambda (i x) (list i x))
         (build-list (length lst) identity)
         lst))))
  
(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))