Hi all, I was using clojure.inspector in my code, and to my surprise it failed when I applied it to a structure containing sets. The error message was that nth is not supported on the type PersistentHashSet. I've included a trivial patch below that seems to fix the problem.
I'm not sure I understand why this is happening though. The API docs note that nth works on seqs in O(n) time, and I thought that a set is- a seq? Explicitly coercing it to a seq seems to work, but what exactly is going on here? Is a new object being created, or are there any other efficiency concerns? Tim Index: src/clj/clojure/inspector.clj =================================================================== --- src/clj/clojure/inspector.clj (revision 1252) +++ src/clj/clojure/inspector.clj (working copy) @@ -31,7 +31,9 @@ (defmethod is-leaf :default [node] (atom? node)) (defmethod get-child :default [parent index] - (nth parent index)) + (if (set? parent) + (nth (seq parent) index) + (nth parent index))) (defmethod get-child-count :default [parent] (count parent)) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---