>want to select the first element in an array
>array[0]
wtf i hate programming now
redefine the index.....oh your language doesn't support that...
>not using linked lists
are you even trying?
>>55749009
use LUA
Just put some junk on the 0th position of every array.
>>55751158
>open source code
>ctrl-F
>DONG
>1 of 30,000
anon get in my office
>>55749009
>tfw argv[0] in C is reserved for the programs name
Literally why?
index = 1 lel
>>55749009#define get(arr, i) *((arr) + (i) - 1)
>>55751421
For the same reasonfalse == 0and5==true
>not using Hasklel
for (int count = 0; count < 10; count++)
Does the thing 10 times, and doesn't need the extra symbol for <=.
What pissed me off more than anything are the languages that decided to index from zero. I have to use Matlab for work and I always have to mentally reset before using C or Python.
>>55751421
>implying the name of the program isn't the first argument you're giving to stdin
>implying the rest of argc aren't your actual arguments
ur dumb anon
>>55751603
For me it goes the other way, I always index from 0 and matlab is pissing me off with the out of bounds errors.
>>55751500Prelude> [1,2,3] !! 1
2
>>55749009
array[0] doesn't literally mean "the first element of array", it's just the usual interpretation, but it really is equivalent to *(array+0), generalized to array[n] === *(array+n).
>>55749009
>look mom, I posted it again! xD
Sage and hide.
>>55749009
It makes more sense when you start using pointers since *(array + 0) == *array.
>>55751776
>>55751603
> use OCTAVE at home, MATLAB at uni, Python at work
REEEEEE
>>55752517
wew
at least drop octave, how can you handle 3 types of syntax at once?
>>55749009
OP is a faggot
>>55752558
> 3 types
HAHAHAHA
If only.
> MATLAB module at uni
> LabVIEW module at uni
> Simulink module at uni
> just started using *NIX system for first time ever
> Python at work
> helping flatmate learn C++
> fucking around with brainfuck in spare time
And that's just this semester.
>arrays
>2016
Just use lists:
>muhList.first();
>>55752637
>brainfuck
waste of time dude
>>55752932
It was fun to screw around with.
>>55749009
#DEFINE FIRST 0
You can shape C anyway you want. Even in retarded ways.
>>55752972#define 0 1
>>55749009
>doing this
>ever
Unless you're still learning then you should stop programming. I hear McDonald's is hiring.
>>55749009int arr[3] = {9,11,13};
C doesn't have first class arrays, they are you pointersassert(*arr = 9);
Since a pointer is a direction of memory and the array has regular size for each slot, you can take the offset of the slot you wantassert(*(arr + 1) = 11);
Which explains why the ``array notation'' is the way it is.assert( arr[0] = *arr ) // 0 offset is the first elementassert( arr[1] = *(arr +1) ) // offset the second element
tl;dr: array notation is about offsets, no elements order
0 index is just easier to calculate.
I sometimes write in a 1 indexed scripting language and I just add one to everything and it gets unreadable.
Make wrapper functions so you get errors when you select out of scope and accept that certain things just makes more sense.
There are several things about C that is really bad, but the indexing is not one of them.
>>55749009
Kys
$first = current($arr);
>muh PHP
>>55749009
kys