> For the complete documentation index, see [llms.txt](https://gitbook.testingwaters.in/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.testingwaters.in/lists/replace-consecutive.md).

# Replace Consecutive

![](/files/-LfzuL3TSb64Sk_rxZEY)

{% file src="/files/-LfzuQ7kXpmATYcBLBow" %}

```d
a = "";
b = "landing";
c = [[a,a,b,a],[a,b,b,b,a,b],[b,b,b,b,b]];

d = List.Sublists(c<1>,(0..1),1);
e = List.Contains(d<1><2><3>,b);
f = List.AllTrue(e<1><2>);
g = List.AllIndicesOf(f<1>,true);
i = List.TakeEveryNthItem(g<1>,2,0);
j = List.SetDifference(0..List.Count(c<1>)-1,i);
k = List.Cycle(a,List.Count(i<1>));
l = List.GetItemAtIndex(c<1>,j<1>);
m = List.Flatten(List.Transpose([l,k])<1>,-1);
n = List.Flatten(List.Transpose([j,i])<1>,-1);
o = List.SortByKey(m<1>,n<1>)["sorted list"];
```
