I wanted to create a function that returns a composition from several other functions, such that
(funcall (compose 'f 'g) x) == (f (gx))
I feel like I was terribly unable to handle this. My best attempt:
(defun compose (funcs) "composes several funcitons into one" (lambda (arg) (if funcs (funcall (car funcs) (funcall (compose (cdr funcs)) arg)) arg)))
But for some reason, the following still returns 0:
(funcall (compose '( (lambda (a) (* a 3)) (lambda (a) (+ a 2)) )) 0)
Is there any way to fix this?
source share