User blog comment:Rgetar/Program demo/@comment-35470197-20181208005010

Good. But why did you use your original collapsing function, which is not well-defined...? If you had used well-defined collapsing functions instead, then your programme would be much greater.