Re: How to catch exception and keep looping?

2010-02-13 Thread Konrad Kułakowski
Thanks Adrian et al. I am going to remove recur from try catch special form. (BTW: doseq is not the case since I need to modify freely the collection during looping) On the other hand I am curios whether no recur inside the try-catch special form might be adopted as a rule of thumb. It is

How to catch exception and keep looping?

2010-02-12 Thread Konrad Kułakowski
I have a piece of code like this: (def ll ['a 'b 'c 'd]) (loop [e (first ll) f (rest ll)] (do (try (do (println e) ;; do sth with e which may throw an exception (recur (first f) (rest f))) (catch Exception _ (println ex))) (println something) (recur

Re: How to catch exception and keep looping?

2010-02-12 Thread Michał Kwiatkowski
2010/2/12 Konrad Kułakowski kulakow...@gmail.com: I have a piece of code like this: (def ll ['a 'b 'c 'd]) (loop [e (first ll) f (rest ll)]  (do    (try       (do          (println e) ;; do sth with e which may throw an exception          (recur (first f) (rest f)))      (catch

Re: How to catch exception and keep looping?

2010-02-12 Thread Adrian Cuthbertson
Here's an idiomatic way of doing what you want; (defn lp [col] (loop [ll (seq col)] (when ll (try (let [itm (first ll)] (if (= itm 'x) (throw (IllegalArgumentException. (str itm not supported.))) (println (str done item: itm