Tassilo and Alan, Thanks for responding. We're new to clj and don't have a good feel of when to you use macros over functions.
(defmacro with-dflt "Runs body in a try/catch returning result of body if no exception otherwise default" [default & body] `(try (do ~@body) (catch Exception _# ~default))) Here's how it could be used with map, but it needs to be wrapped in an anonymous function and I think that was part of your point. (map #(err/with-dflt 42.0 (Double. %)) ["0" "1.5" "3.8e-1" "broken" "0x1.bP2" "Infinity" "NaN"]) (0.0 1.5 0.38 42.0 6.75 Infinity NaN) We are using it in map like this, (map #(err/with-dflt 0.0 (-> % r Double.)) ["Holding" "OA Dur" "OA Cvx" "KRDur 6M" "KRDur 1Y" "KRDur 2Y" "KRDur 5Y" "KRDur 10Y" "Mtge Sprd Dur" "OA Sprd Dur" "Price" "PV" "OA DP/DY" "KR DP/DY 6M" "KR DP/DY 1Y" "KR DP/DY 2Y" "KR DP/DY 5Y" "KR DP/DY 10Y"]) We also wanted to put a default around any form, (err/with-dflt 0.0 (some #(when (= (% "Bench Code") "Bench TSY 10Y") (- > "OA DP/DY" % Double.)) (- >> ctx :run-file-deps :bench :file csv/load-csv)) One style question we have is whether it's worth creating small, specific parse with default functions for doubles and ints or simply to use something like the following inline (err/with-dflt 0.0 (Double. num-str)) If it's worth creating separate parse functions, we were wondering if anybody had packaged up a set already. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en