News for hackers. Stuff that matters.
Re:Designing a programming language to speedrun Advent of Code by ThreeToZero on Tuesday November 14, 2023 @03:30AM (#38260572)
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-...]

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

Re:Designing a programming language to speedrun Advent of Code by bmitc on Tuesday November 14, 2023 @03:58AM (#38260764)
Thanks 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;
Re:Designing a programming language to speedrun Advent of Code by dekhn on Tuesday November 14, 2023 @11:07AM (#38265065)
after 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.