I wanted to create a function, that returns a composition of several other functions, such that
(funcall (compose 'f 'g) x) == (f (g x))
I feel that I miserably failed on this. My best attempt so far:
(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 a way to fix that?
funcs
, so it's value was nil on time of execution? – Tabanid