Hi, I am looking for something which operates similarly as doseq but in case of more than one binding traverses every sequence only one. I.e.
wanted result: (doseq [x '(A B C) y '(1 2 3)] (println (list x y))) should produce: (A 1) (B 2) (C 3) OK I know that in this particular case there are some shorthands like using (doseq [x (indexed '(A B C))] (println (list (second x) (inc (first x)) ))) but I am looking for something general. Be honest I am starting to write a macros: (defmacro foreach [bind-vect expr] `(if (< 0 (count ~(second bind-vect))) (loop [~(symbol (first bind-vect)) (first ~(second bind-vect)) proc# (rest ~(second bind-vect))] (do ~expr (if (< 0 (count proc#)) (recur (first proc#) (next proc#))))))) and for two bindig pairs (defmacro foreach2 [bind-vect expr] `(if (< 0 (count ~(second bind-vect))) (loop [~(symbol (nth bind-vect 0)) (first ~(nth bind-vect 1)) coll1# (rest ~(nth bind-vect 1)) ~(symbol (nth bind-vect 2)) (first ~(nth bind-vect 3)) coll2# (rest ~(nth bind-vect 3))] (do ~expr (if (< 0 (count coll1#)) (recur (first coll1#) (next coll1#) (first coll2#) (next coll2#))))))) but I am not sure whether this is a good solution? On the other hand do you have an idea how to make foreach2 macro more general, handling any length of binding vector? -- 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