Programming languages are missing a thing. When iterating over an array like for(x:elements).. you can’t access the index. If you rewrite the loop to track the index, you have to write boilerplate code. Let’s call this thing -> so we can write for(i->x:elements)..
This -> tracks indices when iterating an array, or keys when iterating a container. But wait, there’s more! Currently you can write a[i]+=1 to increment that element, but it becomes kludgy with as[i]=as[i]*2+1, especially if the array expression is big.
So we can use -> and write old->as[i]=old*2+1. Is this just a funny trick? No, this -> comes from category theory, and reasoning about it is key to understanding how to write generic types and get functor composition right.
You can follow @TimSweeneyEpic.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled:

By continuing to use the site, you are consenting to the use of cookies as explained in our Cookie Policy to improve your experience.