I'm reading "Programming Clojure" and came across this snippet of code:
(defn indexed [coll] (map vector (iterate inc 0) coll)) (defn index-filter [pred coll] (when pred (for [[idx elt] (indexed coll) :when (pred elt)] idx))) I'm having a hard time understanding this. What exactly is 'when pred' checking? I read from the Clojure website that 'when' has the form '(when test & body)'. Going from the sample call '(index-filter #{\a \b} "abcdbbb")', I just don't understand what condition is being checked with 'when pred'. Are we simply checking that pred has values? Secondly, what is happening inside the for structure? [idx elt] are being bound to vector returned by indexed, but that assignment only happens when pred == elt. Finally, we return the vector idx. Is this correct? -- 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