You know you’ve been courting functional programming too long…
…when even your JavaScript code starts looking like this:
function applyTextProcessors(xmlFragment, textProcessors) {
return textProcessors.length == 0 ?
xmlFragment :
applyTextProcessors(
xml.mapTextNodes(
xmlFragment, function(textNode) {
return text.mapMatch(textNode.toString(),
textProcessors[0].regexp,
textProcessors[0].action);
}),
textProcessors.slice(1));
}
Holy cow, this is hard core!
Map functions, haskell-like guards, schema-like tail recursion! Too bad slice() has side-effect, otherwise you may even achieve functional purity!