Forum Discussion

Dicken's avatar
Dicken
Post Prodigy
2 years ago
Solved

Inserting blank into a list ,

Hi,    in the code below is there a way to deal with the fact the last value is  not included, other than what i have don and    let alist = { "a","a","a","a","b","b","b","b","c","c","c","d"} , ...
  • Dicken's avatar
    Dicken
    2 years ago

    Please read post alist = 

     { "a","a","a","a","b","b","b","b","c","c","c","d"} 
  • p45cal's avatar
    2 years ago

    This perhaps?:

     

    let alist = {"a","a","a","a","b","b","b","b","c","c","c","d"}, 
    poslist = {1..List.Count(alist)-1}
    in List.Accumulate(poslist, {alist{0}}, (s,c)=> if alist{c} = alist{c-1} then s & {alist{c}} else s & {"",alist{c}})

     

     resulting in:

    or use null instead of "".