The following operations are used to create new functions from other functions or objects. Often the Dylan compiler will have special knowledge of these operations, to allow for efficient in-line compilation.

When called with just a single argument, compose returns that argument.composefunction1#restmore-functions==>function[Method]

When called with two arguments, compose returns a function that applies the second function to its arguments and then applies the first function to the (single) result value. Thus, cadr could be expressed (compose car cdr).

With three or more arguments, compose composes pairs of argument functions, until a single composite function is obtained. (Because functional composition is associative, the order in which this is performed is unimportant.)

?(define-method sum ((numbers <sequence>))(reduce1 + numbers))sum ?(define-method square ((x <number>)) (* x x))square ?(define-method square-all ((coords <sequence>)) (map square coords)square-all ?(define distance (compose sqrt sum square-all))distance ?(distance '(3 4 5))7.0710678118654755

complement returns a function that appliescomplementpredicate==>function[Method]

?(map female? (list michelle arnold roseanne))(#t #f #t) ?(map (complement female?) (list michelle arnold roseanne))(#f #t #f)

disjoin returns a single function, termed the disjunction of its argument functions. The disjunction accepts any number of arguments and operates by applying the predicates, in order, to the arguments. If any of the predicates returns true, the remaining predicates (if any) are not applied, and the true result is returned. Otherwise, all the predicates will be applied, and #f returned.disjoinpredicate1#restmore-predicates==>function[Method]

A disjunction is similar to an or expression of calls to the predicates.

conjoin returns a single function, termed the conjunction of its argument functions. The conjunction accepts any number of arguments and operates by applying the predicates, in order, to the arguments. If any of the predicates returns #f, the remaining predicates (if any) are not applied and #f is immediately returned. Otherwise, all the predicates will be applied, and the result of the last application is returned.conjoinpredicate1#restmore-predicates==>function[Method]

A conjunction is similar to an and expression of calls to the predicates.

curry returns a function that appliescurryfunction#restcurried-args==>new-function[Method]

?(map (curry + 1) '(3 4 5))(4 5 6)

rcurry (right curry) operates just like curry, except it allows the rightmost arguments ofrcurryfunction#restcurried-args==>new-function[Method]

?(define yuppify (rcurry concatenate ", ayup"))yuppify ?(yuppify "I'm from New Hampsha")"I'm from New Hampsha, ayup"

always returns a function that can be called with any number of arguments. The function ignores its arguments and always returnsalwaysobject==>function[Method]

?((always 1) 'x 'y 'z)1 ?((always #t) #f #f)#t