Data.List.mapAccumR のつかいどころ ref: http://qiita.com/items/389da409cabceebd8ab7