5 ms·
Composable? Julia and composable?!? They decided on sequence range [1...N], instead of [0...N) like Python. Try to compose that.
by Iwan-Zotow 7y ago
Composable? Julia and composable?!?
They decided on sequence range [1...N], instead of [0...N) like Python.
Try to compose that.
- sgt101 7y agoErrm : https://docs.julialang.org/en/v1/devdocs/offset-arrays/ https://docs.julialang.org/en/v1/devdocs/offset-arrays/
- socialdemocrat 7y agoDepends on what you work on. When doing more computer science like stuff, such as computing memory offsets etc, then 0-based indexing is practical. But for numerical work 1-based indexing is usually easier to work with. Mathematical texts are already using 1-based indexing and hence that is what people are used to when thinking about math. I work with both and I never found this a big problem. This is on par with complaining about whitespace in Python. I prefer languages to not be whitespace sensitive but it is not a big problem. Although I pretty sure you will accidentally get more problem from Python whitespace usage than from Julia 1-based indexing. And frankly since Julia can use any indexing, you can use A[begin:end] to refer to the whole range of an object. If you want the second item in any array you can just write A[begin+1].
- giornogiovanna 7y ago> But for numerical work 1-based indexing is usually easier to work with. That's not really true in my experience, since all the nice properties of zero-based indexing transfer perfectly over to mathematics. But you're right, this isn't anything to abandon an otherwise wonderful language over.
- wnoise 7y ago> Mathematical texts are already using 1-based indexing For matrices and vectors, usually. For series and sequences 0-based comes up quite often too.
- Iwan-Zotow 7y agoWhatever I'm doing this is wrong. Simple example - I have Python sequence [0...N) to process. If members are independent, I could split it with easy in Python and do it in parallel: [0...N) -> [0...M) + [M...N) for any M between 0 and N. Basically, Python sequences/ranges/etc are monoids in many cases. Simplest composition rule - monoid, with unit element and associative composition. In Julia it really looks ugly, you have to make some effort to do it right. For me, Julia people don't get range/sequence composition right, so ...
- JustFinishedBSG 7y agoYou're inventing problems that don't exist. Every thing you said is applicable exactly with 1, 2 or whatever based indexing. It literally doesn't matter. Julia's sequences/arrays are monoids too, I don't see what it has to do with anything.
- Iwan-Zotow 7y ago> Every thing you said is applicable exactly with 1, 2 or whatever based indexing. read my statement again, it is about open vs closed interval. Python ranges/sequences are composable, Julia ones are not. > Julia's sequences/arrays are monoids too really? suppose you compute sum, and got two results: S(1, M) and S(M, N) Could you compose them in Julia?
- newen 7y agoYou compute S(1, M-1) and S(M, N) instead and compose them. That's it. This is not complicated stuff.
- stellalo 7y agoWhat does that have to do with anything?
- Iwan-Zotow 7y agoSimple example - I have Python sequence [0...N) to process. If members are independent, I could split it with easy in Python and do it in parallel: [0...N) -> [0...M) + [M...N) for any M between 0 and N. Basically, Python sequences/ranges/etc are monoids in many cases. Simplest composition rule - monoid, with unit element and associative composition. In Julia it really looks ugly, you have to make some effort to do it right. For me, Julia people don't get range/sequence composition right, so ...
- eigenspace 7y agohttps://news.ycombinator.com/item?id=22163210 https://news.ycombinator.com/item?id=22163210
- whataflag 7y ago1 based indexing introduces a whole class of errors that are solved in Rust. Why aren't you using Rust?
- SolarNet 7y agoIt's pretty easy, you use an OffsetArray. Because Julia is composable the shape of the array and the values in it are orthogonal while reaming performant (as discussed by the article). As demonstrated by OffsetArray how one access an array is also orthogonal to those other factors, while remaining performant (it's a zero runtime cost abstraction).
- Iwan-Zotow 7y agoWhy I have to make special efforts to make simple things? Simple example - I have Python sequence [0...N) to process. If members are independent, I could split it with easy in Python and do it in parallel: [0...N) -> [0...M) + [M...N) for any M between 0 and N. Basically, Python sequences/ranges/etc are monoids in many cases. Simplest composition rule - monoid, with unit element and associative composition. In Julia it really looks ugly, you have to make some effort to do it right. For me, Julia people don't get range/sequence composition right, simple thing, basic thing, thus ...
- FranzFerdiNaN 7y ago0-based indexing makes some things harder. Why should i have to make special effort to make those things simple?
- JustFinishedBSG 7y agoIf subtracting 1 when needed is too much work then you have more serious problems that the choice of programming language.