Arrays start at 1

>arrays start at 1

Attached: 1469941373397.gif (459x401, 28K)

Other urls found in this thread:

repl.it/repls/ShortPriceyTruetype
twitter.com/SFWRedditVideos

as they should

Doesnt everything?

no

NO

ℕ = {0, 1, 2, 3...} (if you disagree you're retarded)
Therefore arrays should start at 0, naturally.

Brother, I.....

Attached: hueuheuheuhe.png (256x256, 10K)

I think its the same for lua.

name 34 languages that do this

>Hey user can you count to 10 real quick?

>"Zero, one, two, thr-"

>OH NO NO NO NO NO HE JUST STARTED COUNTING FROM ZERO AHAHAHAHA LOOK AT HIM

Admit you'd start counting from one and move on.

Why do a lot of mathematicians insist ℕ = {1, 2, 3...}

Cardinality is more important than offset when you aren't doing pointer arithmetic.

>Define an array that has 10 elements.
>The 10th element is accessed by the index 9.
>The first element is accessed by the index 0.

>Implying this makes more sense than accessing element 1 with index 1 and element 10 with index 10.

> language isn't arbitrary

you really fucked up when you decided that the natural numbers started with 0

the no curly braces pisses me off

Kinda weird but i think this all started with bits
A 1-bit machine can have two results
0,1
A 2-bit machine can have 4 results.
0(00),1(01),2(10),3(11)
Etc

>pricing starts at $899 plus tax

This guy gets it!

Therefore, this guy is a retard.

Attached: retard-receiving-certificate-congratulations-youre-retarded(1).jpg (489x400, 109K)

They're retarded, real mathematicians like Tao define ℕ = {0, 1, 2, 3, ...}, which is only natural.
It makes no less sense than starting with 1 and ending with 10. Why should it start with 1? Natural numbers are used for counting and they start with zero. It doesn't take long to get used to the fact that up to 10 there are 10 natural numbers, but if you include 10 then you have 11 numbers.
You're retarded.

>it's because of memory addressing

Look at this user who figured it out for themselves. Maybe you're not all retards.

even when in other languages they start at 0 it's wrong, because it still refers to the 1st(first as in 1) element and that's how numbers are. You can't just have 0 and have it be something, 0 is the absence of something

>Why should it start with 1?
Because that's what we use. That's why you say the starting element of any list is the "first" or "1st" element. We associate "1" with being the starting element of a list in any real life talking scenario.

Starting lists with the 0th element sounds completely stupid and forced. It's something decently smart humans just put up with when programming in stupid languages.

>ℕ = {0,
what kind of javascript magician math is this

Attached: 1465619450700.jpg (501x477, 36K)

>count to 10 but not specifying the starting number
if youre counting seconds, it makes no sense to say 0 since you're starting from 0 and counting each second as they elapse. if you're counting object, it makes no sense to start at 0 because 0 means the absence of an object. in real programming languages, arrays are defined in memory and the index is a reference to the offset of an element in the array. that's in reference to the start of that array. therefore it makes sense to start at 0, meaning you are at the first element. nigger.

If you use this or lua you literally get used to it after 30s.

Matlab has column major arrays iirc that's far more annoying

Some constructions of the naturals make it more convenient to define Nat starting at 1 (with a set N' = N U {0} as a auxiliary construction sometimes). It all boils down to how you define the successor function (that is + 1), from native set theory the +1 function goes from a set with 0 to a set without 0 (or more precisely, 0 ain't in the range of +1) and the neat thing is that 1 is both the initial element and the increment value, so in the end its more natural to take the range (that is, the successors set) of the function as the naturals. The 0 comes back when you close Nat under group structure. This kind of construction is mostly used in analysis.

In logic and formal set theory, it makes more sense to define it in terms of symbols 0 and S. So you have 0, S(0), S(S(0)), as a natural is either 0 or the successor of something. Programming comes from this part of mathematics so it's what most languages tend to use (that and of course the binary nature of computers).

I can't remember what, but Python has something that is 1-indexed
Arrays are still 0-indexed though

>retards mistaking addresses with quantity

Attached: 2qb0v7i7yqj21.jpg (640x640, 39K)

>caring about something as trivial as array indexing
>ignoring the other benefits of MATLAB
Get a life.

Attached: 8F105732-7E8F-4DF8-9262-9457B8DAE4CA.jpg (563x651, 226K)

Julia

Matlab the language is trash anyhow - what do you expect?

It's a good thing the open sauce Jupyter and friends are basically winning in comp.sci and generally outside of academia now.

>"hey user how many fingers am I holding up?"
>"9"

Attached: daffy_duck.jpg (719x719, 62K)

No, it's still ten fingers.

How else are you going to account for zero fingers? Zero is assigned to zero fingers.

Fortran's like that too. If it really tickles your autism you can just specify the array to start at 0 or another number

0 is nothing
1 has a value

even databases boolean stores false as 0

it's debatable in high level specialized languages
in low level things that directly access memory starting with 1 fucks pointer math up

ha

All these brainlets don't know that indexing is just syntactic sugar for pointers. All these brainlets that think it makes sense to count from one. All these CompSci brainlets holy shit

>t. Korean

because when you're an analyst you want to write
>let n ∈ N
instead of
>let n ∈ N \ {0}

think of it as an extra null byte

>there are people on Jow Forums right now who don't understand why indexes start at 0

why do I even come here anymore holy shit

Indices in maths notation start at 1 by convention (as far as tensors are concerned, at least), so it makes sense that software primarily aimed at solving maths problems follows this convention. Of course if you're not fucking retarded you can easily adjust to indices starting at 0, -2, 5, -1337 or whatever.

>have a memory address for an array
>let me get the 3rd element of the array
>0x3ff2e + (3* sizeof(element))
:^)

The purpose of starting the index at 0 is so you can have 10 numbers with the same index length (0 to 9). (same applies to 100 etc)

What the fuck are you talking about, that's not how arrays work.

The only true answer.

Array indexes start at zero because to access the first element of an array, you add zero to the pointer, which points to the first location. Arrays starting at zero are purely because that's the way computers work. In maths, everything is indexed at ONE, the first element will have subscript ONE.

It makes total sense that higher level languages start their indexing at 1.

>Python has something that is 1-indexed

Attached: satania_question_mark.jpg (612x716, 90K)

>In maths, everything is indexed at ONE, the first element will have subscript ONE.
No.

Attached: simplex.png (707x289, 24K)

>just waste memory lol

whatever. arr[i] isn't the i-th element of arr, it's the element i positions ahead of the first.

>j=i-1
murica education blows up.

based Fortran is 62 years old and still has a trick or two up its sleeve.

Attached: j4pwao8j3.jpg (610x780, 87K)

threadly reminder

Attached: Screenshot_20190414-015338~01.png (720x413, 26K)

>have 0-indexed list of shit that needs to be accessed by users
>users need to see it in 1-indexed format
>users need to be able to query and modify 1-indexed indices of the 0-indexed list
>multiple cross-referenced lists mixing and matching both index types held as either ints or strings, sometimes for completely arbitrary reasons
>countless man-hours wasted on ensuring conversions and logic between backend 0- and user-facing 1-indexes are handled properly in the inherited shitpile of spaghetti code
I don't know what I did in my previous life to deserve this hell, but I sure fucking hope it was worth it.

no they dont

Lua for one

Well it's marginally more efficient to address linear memory that way. You could just reserve n+1 elements and never use the 0th one, so effectively you have 1-based arrays. Or you could repurpose it to store array length or some other metadata, that way this memory cell is still useful.

The solution is to simply not show the numbers of the index to the user.

Hey user can you count to 10?

Normal person
count = 0 #Okay i will now begin counting
while(count < 10):
count=count+1 #Right now in this instance i will take the previous number and count it up
print count #I am now gonna say the number out loud

(You)
retard = 1 #UUUGH first number is one!
while(retard < 10): #And i have to count to 10??
print retard #UUUGH FIRST NUMBER is ONE!
retard=retard+1 #eeeeh next number
#user stops at 9 because he has no idea how to count to 10

doesn't this count 9/8 times?

nope.

Attached: Download.jpg (768x1024, 118K)

No?
repl.it/repls/ShortPriceyTruetype
>Technology board

I think array[0] should be a symlink to array[1]

Attached: 1555877020352.png (640x752, 509K)

There's nothing wrong with this code
I mean it's dumb and you should never do it, but it makes perfect sense

Try explaining it to my boss.