3 ms·
For 2), in Julia, there is "mod1" function which acts as modulo, with 1 being the smallest value instead of zero. It doesn't really make sense mathematically, b
by elcomet 6y ago
For 2), in Julia, there is "mod1" function which acts as modulo, with 1 being the smallest value instead of zero. It doesn't really make sense mathematically, but is very useful for looping over circular arrays.
- im3w1l 6y agoEDIT: This is actually wrong, because it doesn't correctly describe how negative arguments are handled. It can be phrased mathematically like this: Consider the equivalence relation a ≡ b (mod n). It has n equivalence classes. Use 1..n as the canonical elements for the classes. mod1 takes a number, finds its equivalence class and returns the canonical element.
- user-the-name 6y agoDoes it have it for any other reason than to work around the limitations of 1-based indexing?
- naniwaduni 6y ago12-hour timekeeping, perhaps ;-)