>> On Wed, Dec 2, 2009 at 6:22 PM, Don <josereyno...@gmail.com> wrote: >> > Thank you Stefan and Kevin. Awesome solutions that answer my >> > question. However I actually made a mistake in posing my question. >> > Let me attempt to ask my question again. >> >> > I have 5 vectors as such: >> > a [2 4 6 7] >> > b [1 3 9 2] >> > c [2 4 5 6] >> > d [6 1 3 8] >> > e [4 8 2 1] >> >> > and the output i want is this >> >> > a1 [0 0 0 0] >> > b1 [1 0 0 0] >> > c1 [0 0 0 0] >> > d1 [0 1 0 0] >> > e1 [0 0 1 1]
(defn min-cols [v] (map #(apply min-key % (range (count v))) (apply map vector v))) (defn mark-cols [v m] (map (fn [i] (map #(if % 1 0) (map = m (repeat (count m) i)))) (range (count v)))) (def v [[2 4 6 7] [1 3 9 2] [2 4 5 6] [6 1 3 8] [4 8 2 1]]) user=> (mark-cols v (min-cols v)) ((0 0 0 0) (1 0 0 0) (0 0 0 0) (0 1 0 0) (0 0 1 1)) --Chouser -- 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