Re: 'first vs 'nth on maps

2009-04-22 Thread e
i've noticed a pattern in explanations in clojure that interface and runtime are related. Is that the point being made here? Make expensive things hard or at least explicit? Maybe instead of nth, since that causes controversy, call it "find-nth" or something? On Wed, Apr 22, 2009 at 12:58 P

Re: 'first vs 'nth on maps

2009-04-22 Thread Victor Rodriguez
On Mon, Apr 20, 2009 at 5:17 PM, Hugh Winkler wrote: > > On Mon, Apr 20, 2009 at 1:59 PM, David Nolen wrote: >> Maps aren't ordered so this isn't a good idea anyway. > > It's a good idea if you have a sorted map. My example should have used > sorted-map. > >> The reason first/second work is beca

Re: 'first vs 'nth on maps

2009-04-21 Thread David Nolen
On Mon, Apr 20, 2009 at 5:17 PM, Hugh Winkler wrote > > > Thanks! I think 'nth ought to behave just like 'first and 'second, > don't you? If it's a good idea for 'first it's a good idea for 'nth. > It does seems like a reasonable behavior for sorted-set and sorted-map, but what else really? Also

Re: 'first vs 'nth on maps

2009-04-20 Thread Hugh Winkler
On Mon, Apr 20, 2009 at 1:59 PM, David Nolen wrote: > Maps aren't ordered so this isn't a good idea anyway. It's a good idea if you have a sorted map. My example should have used sorted-map. > The reason first/second work is because they call seq on the collection. > (key (nth (seq {:a 1 :b 2 :

Re: 'first vs 'nth on maps

2009-04-20 Thread David Nolen
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 wrote: > > Hi all, > > Why should 'first and 'second work on maps, but not 'nth? > > u

'first vs 'nth on maps

2009-04-20 Thread hughw
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 clo

Re: nth on maps

2008-08-25 Thread Shawn Hoover
On Mon, Aug 25, 2008 at 9:46 AM, Rich Hickey <[EMAIL PROTECTED]> wrote: > > On Aug 22, 3:59 pm, "Shawn Hoover" <[EMAIL PROTECTED]> wrote: > > While thinking about drewr's map destructuring question on IRC, I found > that > > nth doesn't work on maps. Other group emails state this fact but I can't

Re: nth on maps

2008-08-25 Thread Rich Hickey
On Aug 22, 3:59 pm, "Shawn Hoover" <[EMAIL PROTECTED]> wrote: > While thinking about drewr's map destructuring question on IRC, I found that > nth doesn't work on maps. Other group emails state this fact but I can't > find that it's by design. (doc nth) says it works on sequences. Maps do work >