4 ms·
The post gives an example of how python doesn't have this feature in the section [https://blog.vero.site/post/noulith#coding-with-and-without-infix-functions ht
by ThreeToZero 3y ago
The post gives an example of how python doesn't have this feature in the section [https://blog.vero.site/post/noulith#coding-with-and-without-infix-functions https://blog.vero.site/post/noulith#coding-with-and-without-...]
Python fails this criteria because if you type as you think through the process, you have to move the cursor to the beginning to prefix the 'map' around the input.
For example this series of transforming the input:
puzzle_input.split("\n\n")
map(ints, puzzle_input.split("\n\n"))
map(sum, map(ints, puzzle_input.split("\n\n")))
max(map(sum, map(ints, puzzle_input.split("\n\n"))))
----------------------
Compare to this postfix syntax where you can write this incrementally as you think through the operations:
puzzle_input split "\n\n" map ints map sum then max
- bmitc 3y agoThanks for pointing out that specific example and comparison. The solution seems like it's just a less readable pipeline. puzzle_input split "\n\n" map ints map sum then max; puzzle_input split "\n\n" map ints map sum then sort then (_[-3:]) then sum;
- dekhn 3y agoafter a while, my brain reorganized and i think of the map() first, before thinking about the content of the map, basically to avoid the keystrokes required to go to beginning of line, then back to where I was typing.