News for hackers. Stuff that matters.
Re:Is this the simplest (and most surprising) sorting algori... by hwers on Tuesday October 05, 2021 @09:23AM (#28759059)
what does 1-based mean?
Re:Is this the simplest (and most surprising) sorting algori... by calebegg on Tuesday October 05, 2021 @09:24AM (#28759068)
The first element of the array is A[1], rather than A[0] like it would be in nearly all programming languages.
Re:Is this the simplest (and most surprising) sorting algori... by goatlover on Tuesday October 05, 2021 @11:38AM (#28760907)
Nearly all meaning the non-scientific computing ones, and particularly the ones with syntax inspired by C. Fortran, APL, Matlab, Wolfram, Mathematica, R, Julia, Cobol, Smalltalk and Lua are all 1-based, at least by default.
Re:Is this the simplest (and most surprising) sorting algori... by Scarblac on Tuesday October 05, 2021 @01:36PM (#28762713)
Or maybe not so much inspired by C, but inspired by similar arguments as Dijkstra makes in his "Why numbering should start at zero": https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E....
Re:Is this the simplest (and most surprising) sorting algori... by dredmorbius on Tuesday October 05, 2021 @09:29AM (#28759154)
There is of course the compromise position of 0.5.
Re:Is this the simplest (and most surprising) sorting algori... by DougBTX on Tuesday October 05, 2021 @09:44AM (#28759373)
Re:Is this the simplest (and most surprising) sorting algori... by Joker_vD on Tuesday October 05, 2021 @11:07AM (#28760486)
Huh. I thought it was obvious: e.g., the top-left corner of the screen is (0, 0), the bottom-right corner is (640, 480), and pixels are 1x1 — we take the coordinate of their top-left corner to be their coordinate, so the top-left pixel has coordinates (0, 0), and the bottom-right one has (639, 479), and obviously the coordinates of their centres are (0.5, 0.5) and (639.5, 479.5).

But apparently some people treated pixels as geometrical points without size?

Re:Is this the simplest (and most surprising) sorting algori... by foxfluff on Tuesday October 05, 2021 @01:19PM (#28762431)
It's normal in signal processing to treat samples (whether audio or image) as points. A lot of things stop making sense if you replace them with line segments and rectangles.
Re:Is this the simplest (and most surprising) sorting algori... by tom_ on Tuesday October 05, 2021 @09:41AM (#28759342)
I prefer 9. It makes no less sense than 1, but it is conveniently much closer to the + and - keys.
Re:Is this the simplest (and most surprising) sorting algori... by notriddle on Tuesday October 05, 2021 @09:55AM (#28759531)
My 0 key is twice as big as the rest of the digits.
Re:Is this the simplest (and most surprising) sorting algori... by Scarblac on Tuesday October 05, 2021 @01:31PM (#28762633)
Why compromise? Just have a helpful variable like Perl's $[ to set the first element index.
Re:Is this the simplest (and most surprising) sorting algori... by goohle on Tuesday October 05, 2021 @09:51AM (#28759480)
Which is rounded down to 0 or up to 1 at random.
Re:Is this the simplest (and most surprising) sorting algori... by fullstop on Tuesday October 05, 2021 @09:25AM (#28759087)
The array indexes start at 1, not 0.
Re:Is this the simplest (and most surprising) sorting algori... by red_trumpet on Tuesday October 05, 2021 @09:24AM (#28759073)
It's entries are A[1], A[2],...,A[n] instead of A[0], A[1],...,A[n-1].
Re:Is this the simplest (and most surprising) sorting algori... by jimmyed on Tuesday October 05, 2021 @09:24AM (#28759076)
It means you probably shouldn't be on Hackernews
Re:Is this the simplest (and most surprising) sorting algori... by castis on Tuesday October 05, 2021 @09:32AM (#28759208)
It means they should definitely be on HN where they're very likely to learn new things.
Re:Is this the simplest (and most surprising) sorting algori... by ZeroCool2u on Tuesday October 05, 2021 @09:37AM (#28759277)
Welcoming open, thoughtful discussion and having people much smarter and with more experience than myself available to answer questions in which I'm not an expert is one of the main reasons I frequent HN.
Re:Is this the simplest (and most surprising) sorting algori... by findalex on Tuesday October 05, 2021 @09:41AM (#28759331)
> too young to know FORTRAN.

If you don't know, you don't know.