|Pathologically Eclectic Rubbish Lister|
Re: List::MoreUtils before, after and ... between?by rovf (Priest)
|on Feb 21, 2012 at 15:53 UTC||Need Help??|
I don't think your solution is that bad. If you want to get rid of the two reverse, I think you have to buy and additional list function instead, for instance:
I consider this even more ugly. Alternatively you could try
Whether this is more readable, is something to be questioned, but at least the code can be generalized easier to more than 2 "pattern changes". However, it silently assumes that part traverses the list left to right, which is not guaranteed by the documentation.
Another solution (which does not use reverse) would be
but this is forcing the pairwise function to something in a way it was not really meant to be used (since the result of pairwise is never used).
Maybe you are better off writing a conventional loop and storing the state (inside / outside your pattern sequence) in a status variable, similar to my part example, but without (mis-)using List::MoreUtils.
Ronald Fischer <firstname.lastname@example.org>