3 ms·
Yes, nested functions are probably good for this. (I was about to suggest use of the reader monad in the original comment, but then left out this suggestion fo
by eru 17y ago
Yes, nested functions are probably good for this. (I was about to suggest use of the reader monad in the original comment, but then left out this suggestion for being to arcane (and did not include the nested function suggestion either).)
Nested functions are good for this kind of code, even when they are only used once and do not abstract --- because you have less variables in the innermost scope. (And when you are going to mutate variables at all, then strongly prefer to do it to variables in the innermost scope.)