Add compose-n.

This commit is contained in:
Sergiu Ivanov 2020-12-18 11:43:17 +01:00
parent 8db577d0ff
commit 40eeb1745b
1 changed files with 9 additions and 0 deletions

View File

@ -22,3 +22,12 @@
(module+ test
(require typed/rackunit))
(: compose-n (All (a) (-> (-> a a) * (-> a a))))
(define (compose-n . funcs)
(λ (x)
(for/foldr ([x x]) ([f funcs])
(f x))))
(module+ test
(check-equal? ((compose-n add1 add1 add1) 3) 6))