1
這裏是我嘗試在elisp中實現Maybe monad。它在第一個零上打破它的功能組合。但是value
總是13
。我的錯誤在哪裏?也許monis在elisp
(defun .compose-maybe (&rest funcs)
"Monad Maybe function composition with nil as Nothing."
(lambda (arg)
(if funcs
(let ((value (funcall (apply #'.compose-maybe (cdr funcs)) arg)))
(message "%s" value)
(when value (funcall (car funcs) value))))
arg))
(funcall (.compose-maybe (lambda (x) (* x 5)) (lambda (x) (+ 100 x))) 13)