Playing a bit more with scopes to generalize substitution rules to any predicate on a number and create the substitute function with just one public factory function
Renamed variable and changed order of declarations