On Tue, 05 May 2009 09:39:21 +0200
Christophe Grand <christo...@cgrand.net> wrote:

> 
> Kevin Downey a écrit :
> > (into {} (apply map vector
> >                 '((cars bmw chevrolet ford peugeot)
> >                   (genres adventure horror mystery))))
> >
> > {ford mystery, chevrolet horror, bmw adventure, cars genres}
> >   
> 
> or:
> user=> (apply zipmap '((cars bmw chevrolet ford peugeot) (genres 
> adventure horror mystery)))
> 
> {ford mystery, chevrolet horror, bmw adventure, cars genres}
> 
> But I'm unsure it's what Michel was after. I thought an alist was a
> list of pointed pairs (or a list of 2-elts lists) but I may be wrong
> since I come from Javaland.
> 
> user=> (into {} (map vec '((a 1) (b 2) (c 3))))
> {c 3, b 2, a 1}
> 
> 
> Christophe
> >
> > On Mon, May 4, 2009 at 4:03 PM, Michel S. <michel.syl...@gmail.com>
> > wrote: 
> >>
> >> Yes, me too. The design is a bit unfortunate, as I cannot convert a
> >> Scheme-style association list to a map easily:
> >>
> >> user=> (into {} '((cars bmw chevrolet ford peugeot)
> >>             (genres adventure horror mystery)))
> >>
> >> java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to
> >> java.util.Map$Entry (NO_SOURCE_FILE:0)
> >>
> >> --
> >> Michel
> >>     
> 
> 


In Common Lisp, an alist is something like this:

((cars . genres) (bmw . adventure) (chevrolet . horror) (ford .
mystery))

Where (cars . genres) is a cons cell with values in both slots. So an
alist is a list of key/value pairs where order is significant and keys
could appear more than once. Not much different than:

[[cars genres] [bmw adventure] [chevrolet horror] [ford mystery]]

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

Reply via email to