List.Accumulate-去重复压缩

随手记:全压缩:
file

= List.Accumulate(Text.ToList("AABBACCBE"),{"AABBACCBE","",""},(x,y)=>{x{0},
                                                                       x{1}&(if Text.Contains(x{1},y) then "" else y),
                                                                       x{2}&(if Text.Contains(x{2}, y) then "" else y&Text.From(Text.Length(Text.Select(x{0},{y}))))
                                                                       }
                  )

半压缩:
file

= List.Accumulate(Text.ToList("AABBACCBEAAAMMMQQQ"),{"AABBACCBEAAAMMMQQQ","",""},(x,y)=>{x{0},
                                                                       x{1}&(if Text.Contains(x{1},y) then "" else y),
                                                                       if Text.Contains(Text.End(x{2},2), y) then Text.TrimEnd(x{2},{"0".."9"})&Text.From(Number.From(Text.End(x{2},1))+1)                                                                else x{2}&y&"1"
                                                                       }
                  )

变化结构:
file

= List.Accumulate(Text.ToList("AABBACCBEAAAMMMQQQ")&{""},{"AABBACCBEAAAMMMQQQ","","",1},(x,y)=>{x{0},
                                                                       x{1}&(if Text.Contains(x{1},y) then "" else y),
                                                                      x{2} & (if x{2}=""   then y else if  Text.End(x{2},1)= y then "" else Text.From(x{3})&y), 
                                                                        if Text.End(x{2},1)= y  then x{3}+1 else 1
                                                                       }
                  )

对于压缩,当然有好多方法,这里仅仅是探讨方法和结构