You've now gone and spoilt a perfectly good nonsense thread with some (admittedly obvious) logic and reason!
shame on you... On 16 April 2010 17:27, Reinier Zwitserloot <[email protected]> wrote: > 0 is the only right offset, purely from mathematical principles. > > Here's the reasoning: > > We posit the need for the following concept: > > - A range going from the first element to the last element. i.e. the > ability to describe a 'subList' or 'substring' that makes a copy of > the list. > - A range describing the empty set. > > We'd like for this range to adhere to the following rules: > > RULE 1: Counting elements in a list is in the domain of the natural > numbers. Therefore, if negative numbers are needed the solution is > inferior. > RULE 2: In a list of, say, 10 elements, it would be odd if '11' is > anything other than an Out-Of-Bounds number. > > This is all you need to conclude the superiority of the 0-offset, end > indices markers to the right of the final character system that java > also uses: > > The end index has to be to the RIGHT and not to the LEFT of the final > character. If it was to the LEFT, then you'd need negative numbers to > describe the empty set of a set with 1 element in it. After all: > > list.subList(0, 0) would then describe a list of size 1, whereas we > want one of size 0, so we'd have to write list.subList(0, -1). That's > awkward, so end indices have to work like they do in java. > > Now that we've established why end indices have to work like this, we > can prove that lists have to be 0-based. Let's say I have a list of > 10 elements and I want to describe a sublist that covers everything, > but we live in base 1: > > List copy = list.subList(1, 11); > > Now '11' shows up as a valid number in a 10-length list. That's rather > annoying, as it doesn't feel very natural for 11 to be a meaningful > count into a size 10 list. > > thus, 0 offset: > > List copy = list.subList(0, 10); //Real java, and clearly the 'right' > answer. > > > :) > > On Apr 16, 2:08 pm, Kevin Wright <[email protected]> > wrote: > > Think outside the box! Why must we restrict ourselves to integers? > There's > > some wonderful stuff going on with transcendental numbers right now... > > > > On 16 April 2010 13:03, Wildam Martin <[email protected]> wrote: > > > > > On Fri, Apr 16, 2010 at 13:51, Fabrizio Giudici > > > <[email protected]> wrote: > > > >> Just don't make it 2 :-) > > > > What about -1? Just to be a bit unconventional. > > > > > I think you wanted to say "innovative" instead ov "unconventional". ;-) > > > > > -- > > > Martin Wildam > > > > -- > > Kevin Wright > > > > mail/google talk: [email protected] > > wave: [email protected] > > skype: kev.lee.wright > > twitter: @thecoda > > > > -- > > You received this message because you are subscribed to the Google Groups > "The Java Posse" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > [email protected]<javaposse%[email protected]> > . > > For more options, visit this group athttp:// > groups.google.com/group/javaposse?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "The Java Posse" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<javaposse%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/javaposse?hl=en. > > -- Kevin Wright mail/google talk: [email protected] wave: [email protected] skype: kev.lee.wright twitter: @thecoda -- You received this message because you are subscribed to the Google Groups "The Java Posse" 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/javaposse?hl=en.
