Maps aren't ordered so this isn't a good idea anyway.
The reason first/second work is because they call seq on the collection.
(key (nth (seq {:a 1 :b 2 :c 3}) 1)) -> :b
On Mon, Apr 20, 2009 at 2:51 PM, hughw <[email protected]> wrote:
>
> Hi all,
>
> Why should 'first and 'second work on maps, but not 'nth?
>
> user> (key (first {:a 1 :b 2 :c 3}))
> :a
> user> (key (nth {:a 1 :b 2 :c 3} 0))
> ; Evaluation aborted.
>
> java.lang.UnsupportedOperationException: nth not supported on this
> type: PersistentArrayMap (NO_SOURCE_FILE:0)
> [Thrown class clojure.lang.Compiler$CompilerException]
>
> Thanks,
> Hugh
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---