On Mar 4, 2009, at 14:06, Mibu wrote: > On Mar 4, 2:46 pm, Michael Wood <esiot...@gmail.com> wrote: >> On Wed, Mar 4, 2009 at 2:07 PM, Mibu <mibu.cloj...@gmail.com> wrote: >>> Why does range in Clojure use an inclusive-exclusive range? >> For what it's worth, Python's range function works the same way. > > I think Clojure's design leans towards what's right more than what's > custom even if it breaks old habits, so I am curious why wasn't this > bad habit broken as well. Is it just convention, bad as it is? Or > maybe I'm missing some hidden good reason for using this confusing (to > me) range over an inclusive range.
I wouldn't call it a bad habit just because it's not what you expected. The definition of range used in Clojure (and elsewhere) has some nice properties: (= n (count (range n))) (= (- b a) (count (range a b))) (= (concat (range a b) (range b c)) (range a c)) Their utility may not be obvious immediately, but if you write code that works a lot on indices, you will learn to appreciate them. Konrad. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---