On Dec 6, 2008, at 8:28 PM, Paul Mooser wrote:
That's a good idea, Steve - I didn't totally understand the code you included, but I do always forget that clojure has destructuring in its binding forms, so I rewrote it like this, which I believe should be fine (correct me if I am wrong):
Thanks for the polite correction to my incorrect code. :) What you have looks correct to me.
(defn splode2 [index-path] (with-local-vars [doc-count 0](loop [[document & rest-documents] (filter my-filter-pred (document-seq index-path))](when document (var-set doc-count (inc @doc-count)) (recur rest-documents))) 'done))
For more simplifications with nearly equivalent effect: (defn splode3 [index-path](loop [[document & rest-documents] (filter my-filter-pred (document- seq index-path))]
(when document (recur rest-documents)))) (defn splode4 [index-path] (loop [myseq (filter my-filter-pred (document-seq index-path))] (when (first myseq) (recur (rest myseq))))) (defn splode5 [index-path] (dorun (filter my-filter-pred (document-seq index-path)))) --Steve
smime.p7s
Description: S/MIME cryptographic signature