Re:Automatic Differentiation with Julia
by 0-_-0 on Tuesday October 23, 2018 @10:40AM
(#18283734)
It's not absurd at all. In situations where you need to do modulo arithmetic on array indices 1-based indexing forces you to shift the offset by 1.
[ Parent
| on HN ]
Or, you know, just use the `mod1` function in those cases: https://docs.julialang.org/en/v1/base/math/index.html#Base.m... . Even more fun is that you can use the special `end` index to implement a stupid-simple circular index: `A[mod1(i, end)]` will always be in-bounds for integer `i`.
It's not a common case, though. Using inclusive ranges and 1-based indexing makes Julia's slicing syntax use first-class ranges that can behave like arrays themselves. You can do math on them. You can do all sorts of amazing things that make your life easier: https://julialang.org/blog/2016/02/iteration
Sometimes you want to count fenceposts, and sometimes you want the distance (e.g., offset) from the first post. Keep this imagery in mind and it's easy to do either in any language.
Re:Automatic Differentiation with Julia
by psychometry on Tuesday October 23, 2018 @10:49AM
(#18283827)
Yes and that's something most programmers need to do almost never, so let's not make any important design decisions around that very specific case.