www

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

mapper.rkt (672B)


      1 #lang sweet-exp racket/base
      2 
      3 provide mapper
      4 
      5 require "keyword-lambda.rkt"
      6         "kw-map.rkt"
      7         "partial.rkt"
      8 module+ test
      9   require rackunit
     10 
     11 define mapper
     12   keyword-lambda (kws kw-args . args)
     13     (partial map (keyword-apply partial kws kw-args args))
     14 
     15 module+ test
     16   check-equal? ((mapper add1) '(1 2 3)) '(2 3 4)
     17   check-equal? ((mapper +) '(1 2 3) '(4 5 6)) '(5 7 9)
     18   check-equal? ((mapper + 3) '(1 2 3)) '(4 5 6)
     19   check-equal? ((mapper + 3) '(1 2 3) '(4 5 6)) '(8 10 12)
     20   check-equal? ((mapper app + 3) '(1 2 3) '(4 5 6)) '(8 10 12)
     21   check-equal? ((mapper app) (list add1 sub1) '(0 0)) '(1 -1)
     22   check-equal? ((mapper) (list add1 sub1) '(0 0)) '(1 -1)
     23