Hi folks, we have some code that needs to _not_ be lazy - the rough code we have is:
(defn parse-and-store [raw-data] (try (let [records (split-records raw-data) results (map parse-record records)] (do (save-audit-data! raw-data) (map (save-result! results)))) (catch Exception e (save-error-data! raw-data e))) Where save-audit-data!, save-result! and save-error-data! write to a database. This doesn't work properly, as-is, because in the case of a parsing error, it should only save error data, not audit data or earlier results; but as the parsing is done lazily, you can get a parse error on the 'save-results!' line, by which time audit data has already been saved. What's the idiomatic way to avoid this? The options seem to be either to use (doall (map parse-record records)) or (mapv parse-record records) Is either of these better? The latter is simpler, the former (to me) expresses that you are deliberately forcing non-laziness. Or is there some other alternative? - Korny -- Kornelis Sietsma korny at my surname dot com http://korny.info .fnord { display: none !important; } -- -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.