使用 @ 与元数据写一个指定列表与组合后文本长度,生成不重复组合的列表

  • M函数如下:
let
    fx=(x as list,y as number) as list =>
                let
                    A=List.RemoveLastN(x,y-1),
                    fx2=(x1 as list,y1 as number)=>
                                let
                                   V=if y1=y then x1 else @fx2(S,y1+1),
                                   S=List.TransformMany(x1,each List.Skip(List.RemoveFirstN(x,(n)=>n<>Text.End(_,1)),1),(g,u)=>g&u)

                                in
                                   V
                in
                    fx2(A,1)
in
        fx

第一参数应该是没有重复值,内容为单字符,类型为文本的List,第二参数是组合后文本长度

经过元数据规范化后的M函数:

let
    fx=(x as list,y as number) as list =>
                let
                    A=List.RemoveLastN(x,y-1),
                    fx2=(x1 as list,y1 as number)=>
                                let
                                   V=if y1=y then x1 else @fx2(S,y1+1),
                                   S=List.TransformMany(x1,each List.Skip(List.RemoveFirstN(x,(n)=>n<>Text.End(_,1)),1),(g,u)=>g&u)

                                in
                                   V
                in
                    fx2(A,1),
元数据=type function (x as (type list meta  [Documentation.SampleValues={"没有重复值并且内容为单字符,类型为文本的list"}]),
                     y as (type number meta  [Documentation.SampleValues={"组合数量"}])) as list 

in
    Value.ReplaceType(fx,元数据)

有兴趣的可以看看

Ntt.Docomo