That's a good article. The different perspective from the locals in the area is a good thing to keep in mind. It's really cool to see local communities banding together to protect their lands and their own interests.
This function creates a closure with a private variable, "n". When invoked the closure will increase n by the specified amount, but there is no way to decrease it.
const incfac = () => { let n = 0; return m => (m > 0 ? n += m : n) };
A more extensive example due to Norm Hardy, presuming a multiuser Scheme interpreter that supports ocap security, is this Scheme program for voting on where to have lunch: http://cap-lore.com/CapTheory/Language/Lunch.html
You can translate this into current versions of ES straightforwardly but it doesn't get much more readable.
Norm explains:
> An invocation of mocntr is made each day for each restaurant. It returns a source of options, one of which will be offered to each of the lunch crowd. The second lambda in the definition produces such an option. The variable yet in that proc remembers if the option has been taken. The third lambda produces the getter for the count.
> bb is created each day for lunch and constitutes the ballot box. It is a list of pairs <restuarant name, <option source, count getter>>. This list is iterated over first to send each vote solicitation, and then later to count the votes.
Unfortunately he's vitrified now, so if you send him questions he will answer after a long delay, if ever.
https://harpers.org/archive/2023/11/forbidden-fruit-avocado-...