You may not like it.But 1-indexed arrays are peak design.
>>102436545What difference does it make other than make it simpler for retards?
I prefer using C# for math instead of this bullshit program simply because at one point you're tired of waiting upwards of 60 seconds for a program, C# is faster than this
0-indexed arrays are better
>array memory address + 0 × element size offset this makes way more sense, the advent of zero was the most significant thing in mathematics history.
>>102436545>not using a language with arbitrary indexing
>>102436566>>102436891>>102437010reminder that 0 is not a number.
>>102437010reminder that programming languages are abstractions. the first element being labeled "1" is objectively correct.
>>102436566Usually mathematicians are smarter than your typical cs monkey
>>102437533is that why they pay for matlab when python is free?
>>102437535University pays for this. It works out of box in all scenarios.
>>102437539>universitySorry, I thought you meant intelligent mathematicians.
>>102436545you may like my massive cock
Are there any practical differences or consequences between 0 vs 1 indexing? Or is it just an aesthetic preference?
>>102436545>>102436566>>102437506>>102437693>try executing arr[n % 32]>when n == 32, then resulting code is arr[0]>0 is not a valid index>segmentation faultSo now you need an uglier arr[(n % 32) + 1] just to fix the mistake caused by 1-based indexing, congratulations.There are more examples of this where you need these little n + 1 adjustments, but I'm too lazy right now to look them up.
>>102437836Then you have shit like 'arr.length -1'in zero based
>>102437836If you're gonna create 1 indexed arrays, why not create a "wrap to 1" operator?
>>102437836>people bitching about +1 adjustmentsBoth indexing methods have either their +1 or -1 problem, what about it? Focus on eliminating these instead of attacking the indexing methods.
>>102437950uhm that happens with 1 based too?1, 2, 3 has 3 elements but it's length is 3-1= 2.
>>102437968>Just change how math works, bro
>>102437979Why would it be 2 if it has three entries
>>102437977The point is that 1-based indexing has more of these n + 1 issues and in places that are more annoying, than 0-based indexing has n - 1 issues.
>>102437989because it starts at 1 and ends in 3
>>102437988Youlve never created an operator in a programming language?I'm not saying you should replace modulo, I am saying you can create a new wrap operator.
>>102438003That will make three.size(arr) would result in 3x1 matrix (or 1x3 matrix if you are a faggot) thanks to matlab's 'everything is a matrix unless it's a cell' policy
>>102438017Of fuck me, sorry. It would yield 2x1 matrix with entries 3 1 or 1 3 depending did you initialize a column or a row vector.
>>102438017nah it would make it sqrt(1+4+9)
>>102438002I can only see>[(i % len) + 1]in 1 indexedvs>for (...; i <= len - 1)>len = last_iteration + 1in 0 indexed.What else am I missing?
>>102438007>I'm going to define an entirely new "wrap operator" just to increment a value by one.Found the enterprise Java developer, are you going to write a factory for this operator as well?It's just n + 1, that's it. Or n++ in languages that have an increment operator.
>>102438041>L = length( X ) returns the length of the largest array dimension in X . For vectors, the length is simply the number of elements. For arrays with more dimensions, the length is max(size(X)) . The length of an empty array is zero.Why I haven't used this before? I always called size for vectors when length would yield the result instantly
>>102438045for ( i < len)you moron
>>102438066Now start loop backwards
>>102438049If they created n++ in C-likes, a @ b for matrix multiplication in Python and a <=> b for comparison in Ruby, what's wrong with a potential i whateversymbol n in Lua?
>>102438049Mathematica is basically a 1-indexed Lisp with infix operators for function application and pattern matching, I don't see how this is Java at all.
>>102437988>muh maththe first element of a matrix is usually called a_{1, 1} in linear algebra, retard
>>102438071for ( i = n ; i-- > 0 ; )you moron
>>102438116What is this heresy
>>102438116Okay, let's say that's not a problem for 0 indexed arrays. Can yiu think of any more cases that make 1 indexed worse in this comparison? >>102438045Not trying to be facetious, I'm actually curious.
>>102437950Who normally accesses arrays from the back? The only cases I saw were very contrived like some shit leetcode example or where the front needs to be accessed at the same time. Also you will always save a little time as the tenth element is 9 and starting at 0 is standard already
>>102438326>Who normally accesses arrays from the back?Easy way to reverse a sequence.
>>102436545mucking around with indexing doesn't even qualify as design you freshman shit.
>>102436545>>102436566Most languages had 1-based arrays (actually you can choose the lower and upper bound for each array with 1 as the default because it makes the upper bound the same as the length) but then C shills came along and said "it's LE BAD" because they didn't want people to use those languages. That was just a way to shill C, not because being stuck with 0-based arrays is better.
>>102436545Fortran figured it out first, by allowing the programmer to choose. Indexin starting from something other than 1 can be useful when implementing certain algorithms. Having 0 as default is just some cs bullshit though >>102437200Is this some resurfaced meme, or a real schitzo?
>>102439166>I must customize my language like I customize my body
>>102439640
Many cannot understand arrays or misread them, so I try to get away from them when possible.
>>102439166>using a base other than the default, 0 basedmyarray[index-base]>using a base other than the default, 1 basedmyarray[index-base+1]see the issue?
myarray[index-base]
myarray[index-base+1]
>>102438947"most languages"you stupid fucking faggot, they are and still are 0 based because of the memory accessing speed. its a literal nothing happens operation when you access the very first element at index 0.
>>102438135Using the array indexes as offsets. Like v+i*size.