News for hackers. Stuff that matters.
Re:Taichi Lang by xiaodai on Thursday March 09, 2023 @08:15PM (#35089244)
care to elaborate
Re:Taichi Lang by Iwan-Zotow on Friday March 10, 2023 @08:21PM (#35103991)
In 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.