[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Composing functions of more than 1 argument



A proposal:  (COMPOSE a b ...  z) should allow z to have any
argspectrum, and that would become the argspectrum of the result.  All
the others (a, b, ...)  are unary functions.  The code is trivially
different from the current version:

(DEFINE (COMPOSE . PROCS)
  (COND ((NULL? PROCS) PROJ0)
        ((NULL? (CDR PROCS)) (CAR PROCS))
        (T (LET ((PRELUDE (APPLY COMPOSE (CDR PROCS)))
                 (FINALLY (CAR PROCS)))
             (LAMBDA arglist
               (FINALLY (apply PRELUDE arglist)))))))

(This actually yields an argspectrum of (0 . T), but it works.
Doing it "right" involves some ARGSPECTRUM hair.)
-------