Why Nostr? What is Njump?
2025-02-25 17:21:20
in reply to

Jon Sterling on Nostr: nprofile1q…tcpun nprofile1q…ulpgt There is some cost though... It can be a little ...

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.

Author Public Key
npub1hfga8wmley5fzqtttpeupd8hc6s92rykfmzktm8zfdhu9h8exvqsj9ls8k