神棍 List.Accumulate 案例模型集
本案例不断的累计,更新,
部分案例来源于施阳博客,和努力追赶,凑个完美性和系统性
模型1
let
源 = {"A","A","A","A","B","B","B","B","B","E","E","E","E"},
自定义1 = List.Accumulate(源,{},(x,y)=>if y=List.Last(x) then x else x&{y})
in
自定义1
模型2:
= List.Accumulate(更改的类型,"",(x,y)=>if Text.Contains(x,y) then x else x&y)
模型3:
= List.Accumulate(源&{""},{{},""},(x,y)=>if x{1} ="" then {x{0},y} else if x{1}=y then {x{0},x{1}&y} else {x{0}&{x{1}},y})
模型4:
= List.Accumulate(Text.ToList("ABBCCCDDDDEEEEE")&{""},{{},""},(x,y)=>if x{1} = "" then {x{0} ,y} else if Text.End(x{1},1)=y then {x{0},x{1}&y} else {x{0}&{x{1}},y})
模型5:
= List.Accumulate(Text.ToList("ABBCCC123DDDDE456EEEE"),{"",""},(x,y)=> if y>="A" and y <="z" then {x{0}&y,x{1}} else {x{0},x{1}&y})
模型6:
= List.Accumulate(Text.ToList("ABBCCC123DDDDE456EEEE"),{"",0},(x,y)=> if y>="A" and y <="z" then {x{0}&y,x{1}} else {x{0},x{1}+Number.From(y)})
模型7:
= List.Accumulate(Text.ToList("ABBCCC123DDDDE456EEEE")&{""},{{},""},(x,y)=> if Text.End(x{1},1)&y<":" and y >="A" or y="" then {x{0}&{x{1}},y} else {x{0},x{1}&y})
模型8:
= List.Accumulate(Text.ToList("ABBCCC123DDDDE456EEEE")&{""},{{},""},(x,y)=>if x{1}="" then {x{0},y} else if (y >="A" and y <= "z" and Text.End(x{1},1) <":") or (Text.End(x{1},1)>="A" and y <":") then {x{0}&{x{1}},y} else {x{0},x{1}&y})
模型9:
= List.Accumulate(Text.ToList("ABC123CCGH456ERCd456")&{"B"},{{},"","",""},
(x,y)=> if y >="A" and (x{3} = "" or x{3}>="A") then {x{0},x{1}&y,"", y}
else if y <":" then {x{0},x{1}, x{2}&y, y}
else {x{0}&{{x{1},x{2}}},y,"", y}){0}
模型10:
= List.Accumulate({1..2,4,6..8,10}&{""},{{},"",""},(x,y)=> if x{2}="" then {x{0},y,y}
else if y =x{2}+1 then {x{0},x{1},y}
else if x{1}=x{2} then {x{0}&{Text.From(x{1})},y,y}
else {x{0}&{Text.From(x{1})&Text.From(-x{2})},y,y}){0}
模型11:
= List.Accumulate(Text.ToList("AAAABBBBBccccTTTT")&{0},{"","",0},(x,y)=> if x{1}= "" then {x{0},y,1}
else if y = x{1} then {x{0},x{1},x{2}+1 }
else {x{0}&x{1}&Text.From(x{2}),y,1}){0}
模型12:
= List.Accumulate({"A",null ,null ,"B",null ,null ,null ,"C",null},{},(x,y)=>if y=null then x&List.LastN(x,1) else x&{y})
= List.Accumulate({"A",null ,null ,"B",null ,null ,null ,"C",null},{},(x,y)=>x&{if y=null then List.Last(x) else y })
模型13
= List.Accumulate({"A","A","A","B","B","B","C"},{{},""},(x,y)=>if x{1}=y then {x{0}&{null},y} else {x{0}&{y},y}){0}
模型14
= List.Accumulate(Text.ToList("wew123yyy456")&{""},{{},"",""},(x,y)=>if x{1}="" then {x{0},y,""} else if y>="A" and x{1} >="A" then {x{0},x{1}&y,x{2}} else if y <"A" and y <>"" then {x{0},x{1},x{2}&y} else {x{1},x{2}})
简约就是一种美!!!
自由转载-非商用-非衍生-保持署名(创意共享3.0许可证)