我想创建一个函数,它返回几个其他函数的组合,这样
(funcall (compose 'f 'g) x) == (f (g x))
我觉得我在这方面失败得很惨。到目前为止我最好的尝试:
(defun compose (funcs)
"composes several funcitons into one"
(lambda (arg)
(if funcs
(funcall (car funcs) (funcall (compose (cdr funcs)) arg))
arg)))
但由于某种原因,以下仍然返回 0:
(funcall (compose '(
(lambda (a) (* a 3))
(lambda (a) (+ a 2))
)) 0)
有没有办法解决这个问题?