3 ms·
> Why wouldn't you Because 1. in the original, they were separate as well, 2. the path is derivative of the endpoint 3. you might want to cycle the colours or
by quink 4y ago
> Why wouldn't you
Because 1. in the original, they were separate as well, 2. the path is derivative of the endpoint 3. you might want to cycle the colours or they're a pure derivative calculation based of the number of points or whatnot. So combining them like that is definitely prettier and makes sense if the requirements don't change, but also seems like a premature optimisation. (also, forgot about `key`)
- geocar 4y ago> the path is derivative of the endpoint Oh I didn't notice that from the example. Is it worth splitting off the last two parts for that? > you might want to cycle the colours or they're a pure derivative calculation based of the number of points or whatnot Simply lift color out and use the second argument to map's closure to index it modulo the length of color. If you really anticipate this, you should have %X.length everywhere, otherwise it just looks like a bug the next guy is going to hit and blame you for it. The problem (as I see it) stems from the hardcoded [0,1,2] iota -- if there's a better (domain-specific) way to eliminate it, then great, but it'll have to consider the rank of M's constituents and I just don't think the juice is worth the squeeze. > combining them like that is definitely prettier and makes sense if the requirements don't change, but also seems like a premature optimisation I would urge you to reconsider. Trying to guess what the next person is going to want to do tends to create more code, not less, and changing a little code is better than changing a lot.