use for/list intead of a (one off) map/i function.
This commit is contained in:
parent
45a97cb561
commit
b884623da2
|
@ -49,8 +49,10 @@
|
||||||
(with-syntax ([(i ...) (build-list len add1)])
|
(with-syntax ([(i ...) (build-list len add1)])
|
||||||
#`(define (fn-name args ... . final-arg)
|
#`(define (fn-name args ... . final-arg)
|
||||||
(let ([args (check/normalize 'fn-name 'args args i)] ...
|
(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 ...))))]
|
body ...))))]
|
||||||
[(define/chk (fn-name args ...) body ...)
|
[(define/chk (fn-name args ...) body ...)
|
||||||
(with-syntax ([(i ...) (build-list (length (syntax->list #'(args ...))) add1)]
|
(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)] ...)
|
(let ([arg-ids (check/normalize 'fn-name 'arg-ids arg-ids i)] ...)
|
||||||
body ...)))])))
|
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
|
;; check/normalize : symbol symbol any number -> any
|
||||||
;; based on the name of the argument, checks to see if the input
|
;; 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
|
;; is valid and, if so, transforms it to a specific kind of value
|
||||||
|
|
Loading…
Reference in New Issue
Block a user