4 ms·
To me even more concise and readable is the imperative solution the article also mentions: just refer to a "global" counter and increment it (it doesn't have to
by _delirium 11y ago
To me even more concise and readable is the imperative solution the article also mentions: just refer to a "global" counter and increment it (it doesn't have to actually be global, for that matter, just scoped around the tree-building code). The article doesn't even really argue against that solution. Instead the goal here seems to be more of an intellectual challenge problem: find a functional solution that, unlike the straightforward functional solution (thread state through every function call), is not that much clunkier than the imperative solution.