神棍 List.Accumulate 4

函数介绍:
file
直接上题:二个源的结果会一样的
file
file
还是那句话,解决的办法很多,这是其中的一种:
按要求出牌,这里用List.Accumulate解决
解题思路:
首先结果要的第一个字母是大写的S,其他的字母不需要,x{1} ="" 和 y= "S"同时满足,才能执行x{1}&y
其次字母后面必须连接数字,必须在第一个条件满足的情况下 y 必须是文本数字 ,y>"/" 且 y<":" 才能执行 x{1} &y
其三,只有当 第一步和第二步连接成功,才能把结果移动到列表,这里用x{1} ="" 或者 x{1}的长度小于
6 进行筛选一下,如果条件不对,返回一个空 ,重新寻找 ,下一个结果 ,最后执行将结果移动到列表
废话少说直接上代码:

= List.Accumulate(源,{{},""},(x,y)=>
                if x{1}="" and y ="S" then {x{0},y} 
              else if  y < ":" and y >"/"  then {x{0},x{1}&y} 
               else if x{1} = "" or Text.Length(x{1})<6 then  {x{0} ,""}
                else {x{0}&{x{1}},""}) {0}

源截图:
file
上结果截图:
file

下面是特殊处理的代码'

= List.Accumulate(源&{""},{{},""},(x,y)=>
                if x{1}="" and y ="S" then {x{0},y} 
              else if  y < ":" and y >"/"  then {x{0},x{1}&y} 
               else if x{1} = "" or Text.Length(x{1})<6 then  {x{0} ,""}
                else {x{0}&{x{1}},""}) {0}

源:
file
结果:
file
这就?了,如果对你有帮助,记得给我点赞和打赏