Hi,

I have a code similar to this:

(def pairs (list [1 :a] [2 :b] [3 :c]))
...
(loop [ps pairs, ret {}]
    (cond (empty? ps) ret
             (some-test (first (first ps))) (recur (rest ps) (add-to-
result ret (first (first ps))))
             :true (recur (rest ps) (do-smth-else ret (first (first
ps))))))

You can see that string (first (first ps)), which actually gets first
element of a first vector in pairs, occur many times. I can't move it
before cond, since ps may be empty and evaluating of (first (first
ps)) will produce an error (ok, it won't, but in general case it may).
Is there another way to simplify code to not repeat one form several
times?

-- 
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

Reply via email to