[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: maxresdefault.jpg (37 KB, 1280x720)
37 KB
37 KB JPG
You may not like it.
But 1-indexed arrays are peak design.
>>
>>102436545
What 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.
>>
File: thumb_1200_1553.png (343 KB, 1200x1553)
343 KB
343 KB PNG
>>102436545
>not using a language with arbitrary indexing
>>
>>102436566
>>102436891
>>102437010
reminder that 0 is not a number.
>>
>>102437010
reminder that programming languages are abstractions. the first element being labeled "1" is objectively correct.
>>
>>102436566
Usually mathematicians are smarter than your typical cs monkey
>>
>>102437533
is that why they pay for matlab when python is free?
>>
>>102437535
University pays for this. It works out of box in all scenarios.
>>
>>102437539
>university
Sorry, I thought you meant intelligent mathematicians.
>>
>>102436545
you 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 fault
So 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.
>>
>>102437836
Then you have shit like 'arr.length -1'in zero based
>>
>>102437836
If you're gonna create 1 indexed arrays, why not create a "wrap to 1" operator?
>>
>>102437836
>people bitching about +1 adjustments
Both indexing methods have either their +1 or -1 problem, what about it? Focus on eliminating these instead of attacking the indexing methods.
>>
>>102437950
uhm 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
>>
>>102437979
Why would it be 2 if it has three entries
>>
>>102437977
The 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.
>>
>>102437989
because it starts at 1 and ends in 3
>>
>>102437988
Youlve 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.
>>
>>102438003
That 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
>>
>>102438017
Of 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.
>>
>>102438017
nah it would make it
sqrt(1+4+9)
>>
>>102438002
I can only see
>[(i % len) + 1]
in 1 indexed

vs
>for (...; i <= len - 1)
>len = last_iteration + 1
in 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
>>
>>102438045
for ( i < len)

you moron
>>
>>102438066
Now start loop backwards
>>
>>102438049
If 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?
>>
>>102438049
Mathematica 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 math
the first element of a matrix is usually called a_{1, 1} in linear algebra, retard
>>
>>102438071
for ( i = n ; i-- > 0 ; )

you moron
>>
>>102438116
What is this heresy
>>
>>102438116
Okay, 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? >>102438045

Not trying to be facetious, I'm actually curious.
>>
>>102437950
Who 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.
>>
>>102436545
mucking around with indexing doesn't even qualify as design you freshman shit.
>>
>>102436545
>>102436566
Most 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.
>>
>>102436545
Fortran 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

>>102437200
Is this some resurfaced meme, or a real schitzo?
>>
>>102439166
>I must customize my language like I customize my body
>>
File: 1726650834634887.gif (137 KB, 225x225)
137 KB
137 KB GIF
>>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 based
myarray[index-base]

>using a base other than the default, 1 based
myarray[index-base+1]

see the issue?
>>
>>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.
>>
>>102438135
Using the array indexes as offsets. Like v+i*size.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.