
On 17/08/13 10:11, Christopher Done wrote:
Anyone ever needed this? Me and John Wiegley were discussing a decent name for it, John suggested inv as in involution. E.g. First thing I thought was ‘inverse’…
inv reverse (take 10) inv reverse (dropWhile isDigit) trim = inv reverse (dropWhile isSpace) . dropWhile isSpace
That seems to be the only use-case I've ever come across.
I do this a lot as well. Why not skip the ‘g’ all together and have ‘f . reverse . f’ if that's all we're doing? You could even call it fromEnd at that point and we end up with a rather intuitive ‘fromEnd (drop 10)’. Maybe even just have an operator.
There's also this one:
co f g = f g . g
which means you can write
trim = co (inv reverse) (dropWhile isSpace)
but that's optimizing an ever rarer use-case.
Is this a proposal for addition to something or is it just general discussion? -- Mateusz K.