Add compose-n.
This commit is contained in:
parent
8db577d0ff
commit
40eeb1745b
1 changed files with 9 additions and 0 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Reference in a new issue