Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's not just fun, there's a practicality to the method as well which I believe, judging from the responses, that my example failed to convey.

In another comment, I came up with another example that uses the same pattern that uses a more "practical" example. I'll paste it below:

the goal is to convert:

   {"1":"2", "3":"4", "5":"6"} to {6:1, 2:3, 4:5}
Or essentially the ordered dict, rotated. Which space is a rotation more intuitive? A list space. [1,2,3,4,5,6] is more readily rotated into [6,1,2,3,4,5] with one operation and converted back into a dict.

If you tried to do the above directly by manipulating the dictionary it would not be as straightforward. Use a functor to lift the dict into a list, do the rotation and use the opposite functor to lift it back down to a dict.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: