On Mar 8, 7:59 pm, Brian Carper <briancar...@gmail.com> wrote:
> On Mar 8, 10:53 am, Rich Hickey <richhic...@gmail.com> wrote:>
>
> > In looking at some of the libraries, I am a bit concerned that maps
> > are not being used when the logical entity is in fact a map.
>
> One time I find myself abusing vectors where maps would be better is
> in a situation where I have to retrieve key/value pairs in the order
> they were inserted.
>
> For example I'm working on a DSL for cascading stylesheets, and maps
> should be perfect for specifying property declarations (right down to
> curly braces for maps coincidentally and nicely matching the curly
> braces in literal CSS).
>
> But (css [:div {:padding "1px" :padding-left "5px"}]) won't work
> because the order is lost. Depending on the order "padding" and
> "padding-left" show up in the final CSS, the meaning changes. Not
> sure what the best Clojure idiom would be in this case. Vectors that
> look like maps are the best I've come up with.
How about an ArrayMap?
user=> (def x (array-map :a 11 :b 22 :c 33 :d 44 :e 55))
#'user/x
user=> x
{:a 11, :b 22, :c 33, :d 44, :e 55}
user=> (keys x)
(:a :b :c :d :e)
user=> (vals x)
(11 22 33 44 55)
--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---