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

Until now I have done:
(map vector (take 3 ["a1" "a2" "a3" "b1" "b2" "b3" "c1" "c2" "c3"]))

Which returns (a LazySeq, and I would like a vector):
(["a1"] ["a2"] ["a3"])



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

And I should pick up the first X bigger values between all the
sequences, where X is the number of seats. In this example is 5.
So I should pick up: 55, 32, 55/2, 55/3, 16

And the result for this province would be a map showing, for each
party, the seats that they got. In this example: {"B" 3, "A" 2}



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.


Thanks.

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