First, the fn sorted-map 
<http://grimoire.arrdem.com/1.6.0/clojure.core/sorted_DASH_map/> is 
variable argument and expects to be given (sorted-map :z 1, :b 2, :a 3) and 
not (sorted-map my-map).

To use sorted-map, you'll need to do something like: (apply sorted-map 
(mapcat identity my-map))

Second, when a clojure hash-map is used as a sequence, each key/value pair 
is actually a MapEntry, which behaves like a vector of [key value].  So 
your map fn is effectively doing (vector [1405961887 20]), which produces a 
doubly-wrapped [[1405961887 20]] for each respective element.

On Tuesday, July 22, 2014 11:24:15 AM UTC-5, empt...@gmail.com wrote:
>
> Hi, 
>
> I have an unsorted map:
>
> (def my-map 
> {1405961887 20, 
>  1405960895 20, 
>  1405961919 20, 
>  1405960927 20, 
>  1405960959 21,
>  1405960991 20, 
>  1405961023 20, 
>  1405961055 18,
>  1405961087 23, 
>  1405961119 17, 
>  1405961151 23, 
>  1405961183 19,
>  1405961215 20}
>
> I'd like to be able to sort the map by key and then place each value pair 
> into a vector. 
>
> An attempt at (sorted-map my-map) returns 'No value supplied for key: 
> {1405961887 20 ....' }
>
> When I attempt to create a vector from the key/pairs 
>
> (map #(vector %) my-map)
>
> I receive each key/value in a vector within a vector
>
> ([[1405961887 20]]
>  [[1405960895 20]]
>  [[1405961919 20]]
>  [[1405960927 20]]
>  [[1405960959 21]]
>  [[1405960991 20]]
>  [[1405961023 20]]
>  [[1405961055 18]]
>  [[1405961087 23]]
>  [[1405961119 17]]
>  [[1405961151 23]]
>  [[1405961183 19]]
>  [[1405961215 20]])
>
> My goal is to create a collection of vectors to place in an Incanter 
> dataset:
>
> incanter/dataset ["time" "requests"]
>        [[1405961887 20]
>         [1405960895 20]
>         [[1405961919 20]])
>
> Many Thanks
>
> Adrian
>
>
>
>
>
>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to