user=> (first (first provs))
"p1"
user=>
On Tue, Dec 21, 2010 at 1:18 PM, Benny Tsai wrote:
> 'filter' is for getting a subset of the elements in a collection. For
> getting the names of the provinces, what you want is to get all the
> keys from your 'provs' map, which can be done via the 'keys
'filter' is for getting a subset of the elements in a collection. For
getting the names of the provinces, what you want is to get all the
keys from your 'provs' map, which can be done via the 'keys' function.
user=> (keys provs)
("p1" "p2" "p3" "p4")
Personally, I find ClojureDocs' Quick Referen
Hi again,
I still don't know how to use the filter function.
I have a map of "provinces - seats" like: (def provs {"p1" "5", "p2"
"8", "p3" "13", "p4" "11"})
And a sequence of "province - party - votes" like: (def votes [["A"
"p1" "32"] ["B" "p1" "55"] ["A" "p2" "77"] ["B" "p2" "21"]])
In order
On Mon, Dec 20, 2010 at 5:05 PM, Anclj wrote:
> Thanks a lot for the fast reply!
> Now I have the vector as I wanted.
>
> I have been playing with your code: (map #(/ votes %) (iterate inc 1))
>
> user=> (take 10 (map #(/ 100 %) (iterate inc 1)))
> (100 50 100/3 25 20 50/3 100/7 25/2 100/9 10)
>
>
Thanks a lot for the fast reply!
Now I have the vector as I wanted.
I have been playing with your code: (map #(/ votes %) (iterate inc 1))
user=> (take 10 (map #(/ 100 %) (iterate inc 1)))
(100 50 100/3 25 20 50/3 100/7 25/2 100/9 10)
I have managed to put that in a lazy sequence:
user=> (def ls
Since Ken doesn't mention it explicitly: there's a difference between
vec and vector. (vec x) returns a vector containing all the elements
of x - a vector "view" of x, I think the doc mentions. (vector x)
returns a vector containing the single element x.
On Dec 20, 1:33 pm, Ken Wesson wrote:
> On
On Mon, Dec 20, 2010 at 4:28 PM, Anclj 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"