5 ms·
Already mentioned, in julia just do rand(a). But if you didn't have that, couldn't you just switch out floor for ceil and have the exact equivalent for 1 based
by vcxy 6y ago
Already mentioned, in julia just do rand(a). But if you didn't have that, couldn't you just switch out floor for ceil and have the exact equivalent for 1 based indexing?
- Sebb767 6y agoNo - rnd() can not return one, but can return zero, at which point you'd access index 0 even with ceil().
- vcxy 6y agoAh, thanks! I think I'll stick with rand(indexable_collection) in Julia since anything else just doesn't feel Julian, but I'll remember that for other 1-based languages if I come across it.