-

@ Jon Sterling
2025-02-25 17:21:20
nostr:nprofile1qy2hwumn8ghj7un9d3shjtnddaehgu3wwp6kyqpqkyagcdfagmkfyqwplpv0neng7nq24p4q3l4v7jhe3srlsmntufzs8tcpun nostr:nprofile1qy2hwumn8ghj7un9d3shjtnddaehgu3wwp6kyqpq26zlh0z0afh055uppfrtzhkkr824ya2p9wa3a2ghhj8ntfpnm7xqtulpgt There is some cost though... It can be a little tricky to figure out how to write certain functions in the first place. For example, I had to scratch my head to write this one...
The purpose of the depicted code is basically to build up a list of variables like "n, n-1, n-2, ..., 0". There is an obvious algorithm that is easy to write, but that one is very inefficient; it was comparatively more difficult to figure out how to write the efficient version you see here, and generalising over a "renaming" (f : Ix n -> Ix m) was the crucial idea. It seems even harder to figure out how to write a tail recursive version, but that would be a cool exercise too.
https://media.mathstodon.xyz/media_attachments/files/114/065/668/803/934/261/original/40e5b652d8c06bac.png