From b884623da2d6c0f9426cfde2591db19b5447d368 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Mon, 6 Dec 2010 09:19:53 -0600 Subject: [PATCH] use for/list intead of a (one off) map/i function. --- collects/2htdp/private/img-err.rkt | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/collects/2htdp/private/img-err.rkt b/collects/2htdp/private/img-err.rkt index f877e83da9..eb5d6ca9ed 100644 --- a/collects/2htdp/private/img-err.rkt +++ b/collects/2htdp/private/img-err.rkt @@ -49,8 +49,10 @@ (with-syntax ([(i ...) (build-list len add1)]) #`(define (fn-name args ... . final-arg) (let ([args (check/normalize 'fn-name 'args args i)] ... - [final-arg (map/i (λ (x j) (check/normalize 'fn-name 'final-arg x (+ #,(+ len 1) j))) - final-arg)]) + [final-arg + (for/list ([x (in-list final-arg)] + [j (in-naturals #,(+ len 1))]) + (check/normalize 'fn-name 'final-arg x j))]) body ...))))] [(define/chk (fn-name args ...) body ...) (with-syntax ([(i ...) (build-list (length (syntax->list #'(args ...))) add1)] @@ -70,14 +72,6 @@ (let ([arg-ids (check/normalize 'fn-name 'arg-ids arg-ids i)] ...) body ...)))]))) -(define (map/i f l) - (let loop ([l l] - [i 0]) - (cond - [(null? l) null] - [else (cons (f (car l) i) - (loop (cdr l) (+ i 1)))]))) - ;; check/normalize : symbol symbol any number -> any ;; based on the name of the argument, checks to see if the input ;; is valid and, if so, transforms it to a specific kind of value