Add compose-3 to compose-9.
This commit is contained in:
parent
40eeb1745b
commit
0733e6ab0c
|
@ -31,3 +31,93 @@
|
||||||
|
|
||||||
(module+ test
|
(module+ test
|
||||||
(check-equal? ((compose-n add1 add1 add1) 3) 6))
|
(check-equal? ((compose-n add1 add1 add1) 3) 6))
|
||||||
|
|
||||||
|
(: compose-3 (All (a b c d)
|
||||||
|
(-> (-> c d)
|
||||||
|
(-> b c)
|
||||||
|
(-> a b)
|
||||||
|
(-> a d))))
|
||||||
|
(define (compose-3 f1 f2 f3)
|
||||||
|
(λ (x) (f1 (f2 (f3 x)))))
|
||||||
|
|
||||||
|
(: compose-4 (All (a b c d e)
|
||||||
|
(-> (-> d e)
|
||||||
|
(-> c d)
|
||||||
|
(-> b c)
|
||||||
|
(-> a b)
|
||||||
|
(-> a e))))
|
||||||
|
(define (compose-4 f1 f2 f3 f4)
|
||||||
|
(λ (x) (f1 (f2 (f3 (f4 x))))))
|
||||||
|
|
||||||
|
(: compose-5 (All (a b c d e f)
|
||||||
|
(-> (-> e f)
|
||||||
|
(-> d e)
|
||||||
|
(-> c d)
|
||||||
|
(-> b c)
|
||||||
|
(-> a b)
|
||||||
|
(-> a f))))
|
||||||
|
(define (compose-5 f1 f2 f3 f4 f5)
|
||||||
|
(λ (x) (f1 (f2 (f3 (f4 (f5 x)))))))
|
||||||
|
|
||||||
|
(: compose-6 (All (a b c d e f g)
|
||||||
|
(-> (-> f g)
|
||||||
|
(-> e f)
|
||||||
|
(-> d e)
|
||||||
|
(-> c d)
|
||||||
|
(-> b c)
|
||||||
|
(-> a b)
|
||||||
|
(-> a g))))
|
||||||
|
(define (compose-6 f1 f2 f3 f4 f5 f6)
|
||||||
|
(λ (x) (f1 (f2 (f3 (f4 (f5 (f6 x))))))))
|
||||||
|
|
||||||
|
(: compose-7 (All (a b c d e f g h)
|
||||||
|
(-> (-> g h)
|
||||||
|
(-> f g)
|
||||||
|
(-> e f)
|
||||||
|
(-> d e)
|
||||||
|
(-> c d)
|
||||||
|
(-> b c)
|
||||||
|
(-> a b)
|
||||||
|
(-> a h))))
|
||||||
|
(define (compose-7 f1 f2 f3 f4 f5 f6 f7)
|
||||||
|
(λ (x) (f1 (f2 (f3 (f4 (f5 (f6 (f7 x)))))))))
|
||||||
|
|
||||||
|
(: compose-8 (All (a b c d e f g h i)
|
||||||
|
(-> (-> h i)
|
||||||
|
(-> g h)
|
||||||
|
(-> f g)
|
||||||
|
(-> e f)
|
||||||
|
(-> d e)
|
||||||
|
(-> c d)
|
||||||
|
(-> b c)
|
||||||
|
(-> a b)
|
||||||
|
(-> a i))))
|
||||||
|
(define (compose-8 f1 f2 f3 f4 f5 f6 f7 f8)
|
||||||
|
(λ (x) (f1 (f2 (f3 (f4 (f5 (f6 (f7 (f8 x))))))))))
|
||||||
|
|
||||||
|
(: compose-9 (All (a b c d e f g h i j)
|
||||||
|
(-> (-> i j)
|
||||||
|
(-> h i)
|
||||||
|
(-> g h)
|
||||||
|
(-> f g)
|
||||||
|
(-> e f)
|
||||||
|
(-> d e)
|
||||||
|
(-> c d)
|
||||||
|
(-> b c)
|
||||||
|
(-> a b)
|
||||||
|
(-> a j))))
|
||||||
|
(define (compose-9 f1 f2 f3 f4 f5 f6 f7 f8 f9)
|
||||||
|
(λ (x) (f1 (f2 (f3 (f4 (f5 (f6 (f7 (f8 (f9 x)))))))))))
|
||||||
|
|
||||||
|
(module+ test
|
||||||
|
(define (s->n [s : String]) (cast (string->number s) Number))
|
||||||
|
(define (n->s [n : Number]) (number->string n))
|
||||||
|
(check-equal? ((compose-3 n->s add1 s->n) "3") "4")
|
||||||
|
(check-equal? ((compose-4 n->s add1 add1 s->n) "3") "5")
|
||||||
|
(check-equal? ((compose-5 n->s add1 add1 add1 s->n) "3") "6")
|
||||||
|
(check-equal? ((compose-6 n->s add1 add1 add1 add1 s->n) "3") "7")
|
||||||
|
(check-equal? ((compose-7 n->s add1 add1 add1 add1 add1 s->n) "3") "8")
|
||||||
|
(check-equal?
|
||||||
|
((compose-8 n->s add1 add1 add1 add1 add1 add1 s->n) "3") "9")
|
||||||
|
(check-equal?
|
||||||
|
((compose-9 n->s add1 add1 add1 add1 add1 add1 add1 s->n) "3") "10"))
|
||||||
|
|
Loading…
Reference in New Issue