www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit bef3f896e8cc7720ff93581d9b3ef6d82d661765
parent 1d0c9b31b985ced42338c844a05b9487ce0aa9ff
Author: AlexKnauth <alexander@knauth.org>
Date:   Tue, 28 Jul 2015 23:45:50 -0400

add mapper.rkt

Diffstat:
Akw-utils/mapper.rkt | 21+++++++++++++++++++++
1 file changed, 21 insertions(+), 0 deletions(-)

diff --git a/kw-utils/mapper.rkt b/kw-utils/mapper.rkt @@ -0,0 +1,21 @@ +#lang sweet-exp racket/base + +provide mapper + +require "keyword-lambda.rkt" + "kw-map.rkt" + "partial.rkt" +module+ test + require rackunit + +define mapper + keyword-lambda (kws kw-args . args) + (partial map (keyword-apply partial kws kw-args args)) + +module+ test + check-equal? ((mapper add1) '(1 2 3)) '(2 3 4) + check-equal? ((mapper +) '(1 2 3) '(4 5 6)) '(5 7 9) + check-equal? ((mapper + 3) '(1 2 3) '(4 5 6)) '(8 10 12) + check-equal? ((mapper app + 3) '(1 2 3) '(4 5 6)) '(8 10 12) + check-equal? ((mapper) (list add1 sub1) '(0 0)) '(1 -1) +