4 ms·
care to elaborate
by xiaodai 4y ago
care to elaborate
- Iwan-Zotow 4y agoIn C and Python (which inherited it from C, I believe) for(int k = 0; k != N; ++k) { dowork(k); }, similar in Python ranges are [0...N). If I want just a sum, and would like to split work among multiple CPUs, I could write s = sum(0...N) or s = sum(0...N/2) + sum(N/2...N) or s = sum(0...N/3) + sum(N/3...5N/7) + sum(5N/7...N) and it will work beautifully. Ranges are decomposable and composable with any number(s) splitting original range. [0...N/2) + [N/2...N) = [0...N) When I first looked at Julia, I was ... unhappy. They didn't get simple ranges composability right. You could do it, sure, but it looks so ... unnnatural.