optimize mapAccumLeft and mapAccumRight. avoid stack overflow