Maybe in clojure
问题 Trying to write a composed function in clojure that exits at the first nil value, (e.g something you'd do by chaining Maybes together in haskell) with the following: (defn wrap [f] (fn [x] (if (nil? x) nil (f x)))) (defn maybe [arg & functs] ( (comp (reverse (map wrap functs))) arg)) So that I'd get, e.g. (defn f1 [x] (+ x 1)) (maybe 1 f1 f1 ) => 3 (maybe nil f1 f1) => nil Which is unfortunately giving me this: ClassCastException clojure.lang.PersistentList cannot be cast to clojure.lang.IFn