mapAccumLeft and mapAccumRight test
optimize mapAccumLeft and mapAccumRight. avoid stack overflow