martin-fowler's https://en.wikipedia.org/wiki/Rule_of_three_(computer_programming). It states that two instances of similar code do not require refactoring, but when similar code is used three times, it should be extracted into a new procedure.
The fundamental idea of Don’t Repeat Yourself is not “never write similar code twice”, but rather, as Wikipedia helpfully points out “every piece of knowledge must have a single, unambiguous, authoritative representation in the system”.
The real value of DRY is not in the mechanism domain of the program at all; the underlying computational machinery, like our memoizer above, is what I mean by the mechanism. You can tell it is a mechanism because this code is not part of the business domain of the program
These things are themselves representations of knowledge otherwise they’re the springs and gears of the machine that represents the knowledge, which can composedly be duplicated.