4 ms·
My first thought when I read sum(x+3, 1, 4) was x+3+1+4. Also it should be sum(x+3, x, 1, 4) since you need to encode what the iterator variable is as well.
by serbuvlad 1y ago
My first thought when I read sum(x+3, 1, 4) was x+3+1+4.
Also it should be sum(x+3, x, 1, 4) since you need to encode what the iterator variable is as well.
- Izkata 1y agoI thought that was it too, but you're saying it's not..? I've been thinking about it for a few minutes now and I still can't figure out what other meaning it could have. Edit: Oh wait, someone else mentions map/filter, did they mean this as a combination of range->map->sum and the latter two numbers are the range portion, like sum(map(x+3, 1..4)) ? Edit2: And now I'm remembering sigma. I think it would have been more obvious to me if the order was flipped and your issue handled the way it is in that notation: sum(x=1, 4, x+3), though I'd still prefer the range notation: sum(x=1..4, x+3)
- serbuvlad 1y agoYep. I agree and now we've basically reinvented sigma. Take the x=1 and put it below, take the 4 and put it above take the x+3 and put it to the right. Granted I always found sigma a bit quirky for separating the range ends like that. Either x below and 1..4 above, or x=1..4 below/above would have been more intuitive. But it's just a notation you learn once and then you know it.