Function: COMPOSE

Documentation

composing a number of functions. Every function, but the last one, must take exaclty one argument.

Source

(defun compose (&rest fns)
  "composing a number of functions.
   Every function, but the last one, must take exaclty one argument."
  (if fns
      (let ((fn1 (last1 fns))
	    (fns (butlast fns)))
	(lambda (&rest args)
	  (reduce #'funcall fns
		  :from-end t
		  :initial-value (apply fn1 args))))
      #'identity))
Source Context