An introduction to the Julia language, part 1
An introduction to the Julia language, part 1
Posted Aug 31, 2018 8:22 UTC (Fri) by jem (subscriber, #24231)In reply to: An introduction to the Julia language, part 1 by rsidd
Parent article: An introduction to the Julia language, part 1
Just about anything cyclic. Let's say you keep a count of events classified by during which hour of the day they happened. Do you use an array with indices 0..23 or 1..24? (Or maybe two arrays, am and pm, each with indices 12,1,2,3,4,5,6,7,8,9,10,11?)
Posted Aug 31, 2018 10:44 UTC (Fri)
by geert (subscriber, #98403)
[Link]
Posted Aug 31, 2018 15:26 UTC (Fri)
by hackerb9 (guest, #21928)
[Link] (2 responses)
Posted Aug 31, 2018 15:59 UTC (Fri)
by farnz (subscriber, #17727)
[Link] (1 responses)
Or go further, as some places in Japan do. A bar can be open (say) 1800 to 2700, meaning in 12 hour terms "from 6pm today until 3am tomorrow"; similarly, a long distance transit route might have the last vehicle today leaving at 2330 and arriving at 2530 (meaning 0130 tomorrow), while the next vehicle leaves at 0015 and arrives at 0215.
Basically, today started at 0000 - time then runs continuously so that 2530 today is the same as 0130 tomorrow, and 4930 today is the same as 0130 in two days time.
Posted Aug 31, 2018 16:08 UTC (Fri)
by rsidd (subscriber, #2582)
[Link]
Zero-indexing makes sense for "discretized" continuous or periodic things. It makes sense to label the first hour after midnight the zero hour: the markers are 0 and 1, at either end, and even for continuous periodic things, the "mod" argument makes some sense for zero-indexing.
For sequences in general, nobody refers to "a" as the zeroth letter in the word "algorithm". It is the first letter. This is just how daily language works and also how mathematical notation works for the most part. The FFT may start from a zero-index but that's fundamentally because it's based on an assumption that the sequence is periodic. Vectors are always 1-indexed, except in relativity where time gets the index 0 while spatial indices are 1,2,3 -- and that too is for historic reasons (originally time was 4, but in imaginary units; when they figured it's better to use real units and a non-Euclidean metric, they chose 0 to avoid confusion.)
An introduction to the Julia language, part 1
Great for conference calls in multiple time zones. You won't be the first to join the meeting one day early or one day late ;-)
Or do it like I've been told the U.S. Army does: 0..24. 0 and 24 refer to the same hour, but they use them to make the rest of the context consistent: for example, We are meeting in the War Room from 23:00 to 24:00 and then having an ice cream social from 0:00 to 1:00.
An introduction to the Julia language, part 1
An introduction to the Julia language, part 1
An introduction to the Julia language, part 1
