Extract duplicate code into a function.

'rainbow-delimiters--category-propertize' and
'rainbow-delimiters--face-propertize*' use essentially the same code
around their loops, move the common part to a function and convert
the loop bodies to lambdas.