7.7
5 map with keyword arguments
(require kw-utils/kw-map) | package: kw-utils |
procedure
(map proc lst ... #:<kw> lst2 ...) → list?
proc : procedure? lst : list? lst2 : list?
like map from racket/base
, but accepts keyword arguments as
well as positional arguments.
Examples:
> (require kw-utils/kw-map racket/math) > (map (λ (x) (+ x 1)) '(1 2 3 4)) '(2 3 4 5)
> (map (λ (#:x x) (+ x 1)) #:x '(1 2 3 4)) '(2 3 4 5)
> (map (λ (x y) (+ x y)) '(1 2 3 4) '(10 100 1000 10000)) '(11 102 1003 10004)
> (map (λ (x #:y y) (+ x y)) '(1 2 3 4) #:y '(10 100 1000 10000)) '(11 102 1003 10004)
> (define (KE #:m m #:v v) (* 1/2 m (sqr v))) > (map KE #:m '(2 2 2 2) #:v '(0 1 2 3)) '(0 1 4 9)
> (map KE #:m '(0 1 2 3) #:v '(0 1 2 3)) '(0 1/2 4 27/2)
> (map KE #:m '(1 2 1/2 2/9) #:v '(0 1 2 3)) '(0 1 1 1)