added a nullary case to compose
svn: r14697
This commit is contained in:
parent
a1b65fb055
commit
a1d943146b
|
@ -247,6 +247,7 @@
|
|||
(call-with-values (lambda () (g a)) f))
|
||||
(lambda args
|
||||
(call-with-values (lambda () (apply g args)) f)))))]
|
||||
[() values]
|
||||
[(f . more)
|
||||
(if (procedure? f)
|
||||
(let ([m (apply compose more)])
|
||||
|
|
|
@ -38,7 +38,8 @@ Returns a procedure that composes the given functions, applying the
|
|||
last @scheme[proc] first and the first @scheme[proc] last. The
|
||||
composed functions can consume and produce any number of values, as
|
||||
long as each function produces as many values as the preceding
|
||||
function consumes.
|
||||
function consumes. When no @scheme[proc] arguments are given, the
|
||||
result is @scheme[values].
|
||||
|
||||
@mz-examples[
|
||||
((compose - sqrt) 10)
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
(test 'hi (compose (case-lambda [(x) 'bye][(y z) 'hi]) (lambda () (values 1 2))))
|
||||
(test 'ok (compose (lambda () 'ok) (lambda () (values))))
|
||||
(test 'ok (compose (lambda () 'ok) (lambda (w) (values))) 5)
|
||||
(test 0 (compose) 0)
|
||||
(test-values '(1 2 3) (lambda () ((compose (lambda (x) (values x (add1 x) (+ x 2))) (lambda (y) y)) 1)))
|
||||
|
||||
(err/rt-test (compose 5))
|
||||
|
|
Loading…
Reference in New Issue
Block a user