Creating map from string

2010-12-03 Thread Anclj
Hi, I have a string of data and I would like to get a map {:key value, :key value, …} How could I do that? I've got: user> (split (slurp "data") #",") ["0" "2" "1" "5" "2" "8" "3" "15" "4" "9"] And I would like: {:0 2, :1 5, :2 8, :3 15, :4 9} Any idea? Thanks. -- You received this message

Re: Creating map from string

2010-12-07 Thread Anclj
Thanks a lot for all the answers :) I've been busy trying to understand all the scripts that you posted. The code works but I also wanted to know why. I'm new to Clojure and it's hard for me to understand "advanced code", but looking through the docs and the api I'm learning a lot. Cheers! On 4

Working with maps and vectors

2010-12-20 Thread Anclj
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 (ta

Re: Working with maps and vectors

2010-12-20 Thread Anclj
taining 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 Mon, Dec 20, 2010 at 4:28 PM, Anclj wrote: >

Re: Working with maps and vectors

2010-12-21 Thread Anclj
e: (defn getseq [prov party] (...)) But I don't know how to get each province ("p1", "p2", "p3", ...). Doing: (take 1 provs) I get: (["p1" "5"]) Any idea of how could I get "p1"? So I can make a recursive call to my getseq function