Alter by Boolean Sequence

Chop list at indices where there is a change in value

Sequentially number true blocks
def numTruSqn (lst01:var[]..[])
{
	//Seperate consecutive true and false
	cns01 = List.DropItems(lst01,1) == List.DropItems(lst01,-1);
	cns02 = List.Flatten([-1, List.AllIndicesOf(cns01,false),List.Count(lst01)-1], -1);
	cns03 = List.DropItems(cns02,1) - List.DropItems(cns02,-1);
	lst02 = List.Chop(lst01,cns03);

	// Assign value to true
	lst03 = List.Flatten(List.UniqueItems(lst02<1>));
	lst04 = Math.Sum(List.TakeItems(lst03 == true ? 1 : 0, 1..List.Count(lst03)));
	return lst02 == true ? lst04 : 0;
};
Replace trues sequentially with elements from another list
List chopped to correspond with true/false sequence
Variation in which the first item varies from the rest

Last updated