Forum Discussion
Dicken
2 years agoPost Prodigy
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"} , ...
- 2 years ago
Please read post alist =
{ "a","a","a","a","b","b","b","b","c","c","c","d"} - 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 "".
AlienSx
2 years agoSuper User
please show us what you have as a start (presumably alist) and what you want to get in the end. We don't need your code. Thanks.
Dicken
2 years agoPost Prodigy
and what I want at teh end =
{ "a","a","a","a","b","b","b","b","c","c","c","d"} , but with a space inserted into between each but want to use an accumlation that does includes the last value as said I used
s & { alist {c} , "", List.Last( alist) } )
I think I've come up wiht a better way of including the last value.