|
A century has an unambiguous starting point, so 2010 and 2020 would be correct. This would indeed be [9] and [19] if [0]=2001.
|
|
|
|
|
Um, no. There was no year zero, so year 100 was the end of the first centry, 101 the beginning of the second century, etc.
|
|
|
|
|
Yes, and so 2001 was the beginning of the 21st century, with 2010 being its 10th year.
|
|
|
|
|
Quote: There was no year zero Yes there was. It was the year just before year 1. If C, C+=, C# programmers were around then (who knows?), then there was a Year 0. If there were only VB programmers then there wasn't.
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
The Church disagees. 1BC was followed by 1AD. There was no 0BC/8AD inbetween.
This has been recognized by historicans for decennies, maybe centuries. Today, it is also recognized by all (serious) developers of computer software handling historic data, hereunder genealogical information.
Enjoy it or hate it - your choice! In our office building, our elevator goes directly from floor 1 to floor -1. For our mental comfort, we declared that there is in fact a floor 0 inbetween them, but it is virtual. And since it is virtual, the elevator operating in real space cannot make a stop in virtual space - that is why it skips directly from 1 to -1.
We have learned to live with it. Similarly, you will have to learn with years skipping directly from -1 to 1 without a stop at 0.
|
|
|
|
|
Quote: The Church disagees. The church can't spell and I disagree with it anyway. I live in this world and I can make my own assumptions for my world view. I don't need anyone else to agree with me except when necessary. To be polite, I will agree with other people when necessary.
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
Let it be noted that in civilized countries, the ground floor is floor number zero.
|
|
|
|
|
You also have ground floors. The floors in uncivilized countries are not the ground, it is raised from the ground, usually by a either a layer of concrete or wooden beams, and then a layer of planks above that, usually topped by tiles, carpeting or e.g. a vinyl cover. We prefer that, compared to walking directly on the ground ... even if it less civilized.
|
|
|
|
|
VB arrays have an 0th element by default. It's just ignored/skipped by many programmers. The confusion of caused that the DIM statement doesn't actually give the dimension (as the equivalent in C/C++/C# does), but instead the upper limit.
Truth,
James
|
|
|
|
|
I'm with Greg on that one!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Your option 1 is precisely how I interpret the question. I could understand forgetting to start the index at 0 (getting some of #2), but printing the first index regardless is incorrect.
|
|
|
|
|
I don't think it's a question of English. "Every 10th number" is clear, but where to start means making an assumption. If stated in another language that I can read, I would feel the same way.
|
|
|
|
|
Greg Utas wrote: but where to start means making an assumption. I am not making any assumption. I am starting from the beginning of the array.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Nelek wrote: a[0], a[10], a[20]... which are places 1st, 11th, 21st Don't you mean zeroth, tenth, etc?
|
|
|
|
|
From what base?
Yet another poorly-worded spec. You definitely need to know which element to start with. It should at least be something along the lines of, "starting with element n, select every mth element".
To cover the variants I can think of at the moment, I would write a method which takes three parameters: the index of the first element to select, how many elements to select from that position, and the number of elements to skip to get to the next element to select.
modified 12-Mar-20 19:46pm.
|
|
|
|
|
The ID of the first element of the array is irrelevant.
If you have an array that starts with an element identified as a(47), then the tenth element is a(56).
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
This explanation makes sense also for a protozoon like me.
It does not solve my Problem, but it answers my question
modified 19-Jan-21 21:04pm.
|
|
|
|
|
That's why people keep hiring me to do things with the English language, rather than C#.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
So you consider element 47 not as the first one.
The ninth element is #55, the eigth is #54... the 1st is #48, the 0th is #47. Fair enough, from a programmer point of view. Your grandmother might disaggree. But as we all know: Today, computer guys rule the world.
In sports games, we still rank the competitors as "1st place", "2nd place" and "3rd place". As soon as computer guys succeed in taking over sports, it most surelu will be changed to "0th place", "1st place" and "2nd place"...
|
|
|
|
|
Member 7989122 wrote: So you consider element 47 not as the first one. I think you must have misread. Element a(47) is the first element.
Treat the "a(47)" as an identifier (which is precisely what it is) and not as something to do with its cardinality.
It's like you can have variables named 'a', 'b', and 'c', but those names/identifiers have nothing to do with the order they're used in, their importance, etc.
"An array element by any other name would still be in the same cardinal position" -- Wm. Shakespeare, who predicted the existence of arrays centuries before computers were built.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
I agree.
Let's say you're instructed to "get on the highway headed east and drive to the second exit". You don't count the interchange you enter at. Nor do you consider where "exit 2" might be -- you may have entered at exit 2, or it may be to your west.
So "every tenth" has nothing to with how the elements may be indexed, only with which order they're encountered in.
For that matter, does it matter if an array cell is empty? Would those count?
|
|
|
|
|
PIEBALDconsult wrote: For that matter, does it matter if an array cell is empty? Would those count? Sure. If a hotel clerk has to check the tenth pigeonhole from the left for mail, he doesn't skip the empty ones.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
True, so it depends on the task.
A customs clerk who is checking every tenth boat in the harbor will skip empty slips.
|
|
|
|
|
I don't think this is a question about English but about "Computerese".
A well known joke is that "Computer amateurs think 256 is a round number. Real computer guys consider 255 a round number - they count from zero."
Before computer guys took over the world, arrays could have any base. In Pascal, an array could run from index 1814 to 2050. Ordinary people could relate to it, e.g. as years. That reduced the importance of the Computer Guys, so they detested it. Even the Fortran style, where the first element of array a was a[1], was too obvious to Common Man, reducing the power of the Computer Guy. Luckily, base zero index won the war. (There is only a small problem left: What if there is no "zero" element, like in the calender? What happened in year 1 belongs in eventsOfYear[1], but what about eventsOfYear[0]? That year never existed! Year -1 was immediately followed by year 1! ... Fortunately, the Unix epoch doesn't apply to historic dates!)
Yet, there is a question of where "every 10th" is counted from: Is the "first" (or zeroth, if you like) every tenth element the one with the lowest index, the one with the tenth lowest index, or the one ten above the lowest index? If we had had a quantum computer, it could have provided all three results, with varying degrees of probability/validity.
|
|
|
|
|
Even early FORTRAN compilers used the trick of using address of A(n) as being (address of fictitious A(0)) + (n * width of data type of A); or as the literature of the day put it (address of A(1)) + (n - 1) * (width of data type A)
[historical note: versions of FORTRAN prior to 1977 only had uppercase variable name and all versions used '(' and ')', not '[' and ']'; but that doesn't affect the validity of what I am saying]
|
|
|
|