Add compose-n.
This commit is contained in:
parent
8db577d0ff
commit
40eeb1745b
|
@ -22,3 +22,12 @@
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(require typed/rackunit))
|
(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))
|
||||||
|
|
Loading…
Reference in New Issue