This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ;;Examples: ;;(ithsmallest 1 '(3 5 2 4 1)) => 1 ;;(ithsmallest 2 '(3 5 2 4 1)) => 2 ;;(ithsmallest 5 '(3 5 2 4 1)) => 5 (define (ithsmallest i alon) (local [;; listmin: (listof num)[nonempty] > num ;; produces the smallest value of the list inputted. (define (listmin lon) (foldr min (first lon) lon))] (cond [(= i 1)(listmin alon)] [else (ithsmallest ( i 1) (filter (lambda (x)(not (= (listmin alon) x))) alon))]))) ;;Tests: (checkexpect (ithsmallest 1 '(3 5 2 4 1)) 1) (checkexpect (ithsmallest 2 '(3 5 2 4 1)) 2) (checkexpect (ithsmallest 5 '(3 5 2 4 1)) 5)...
View Full
Document
 Fall '09
 T.VASIGA
 Computer Science

Click to edit the document details