On Mon, Dec 20, 2010 at 4:28 PM, Anclj <anb...@gmail.com> wrote: > Hi, > > I have some questions related with maps and vectors, if someone can > help me I will appreciate it a lot. > > I have a vector like: > ["a1" "a2" "a3" "b1" "b2" "b3" "c1" "c2" "c3"] > > And I would like to have: > [["a1" "a2" "a3"] ["b1" "b2" "b3"] ["c1" "c2" "c3"]]
user=> (into [] (map vec (partition 3 [1 2 3 4 5 6 7 8 9]))) [[1 2 3] [4 5 6] [7 8 9]] > I have a map that represents provinces and seats, like this: > {"p1" "5", "p2" "8", "p3" "13", "p4" "11"} > > Which means that in "p1" 5 seats will be distributed, 8 for "p2", and > so on. > > > And a vector where its elements are vectors formed by a political > party, a province and the votes he got. Like this: > [["A" "p1" "32"] ["B" "p1" "55"] ["A" "p2" "77"] ["B" "p2" "21"] ...] > > > I need, for each province, to distribute the seats among the parties > according to the number of votes following this rule: > > For each party, i should get a lazy sequence with the values of: > #votes/1, #votes/2, #votes/3, #votes/4, ... > > So, in this example, for the "p1" province I would have: > For A party: 32, 16, 32/3, 8, ... > And for B party: 55, 55/2, 55/3, 55/4, ... (map #(/ votes %) (iterate inc 1)) > I'm not familiar with Clojure, and I don't know how to use many > functions. Any reference to high-level functions that I should use, > and how to use them will be appreciated. Hope the above gets you started. Obviously it won't do any more than that -- partly because I don't have much time right now and partly because I suspect I might be doing your homework for you if I went much further. :) -- 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