Ad
  • Custom User Avatar

    As it reads

    1. Select each number and it's index (0 based position) in the list
    2. If current number equal to previous number in List (ignoring index 0 because no previous number) add null entry to new returned enumerable
    3. Else [Implied If current number not equal to previous number - i.e. beginning of new sequence] Skip(i) amount of elements up to current position and Take() the next value in this sub-enumerable While() next value is equal to current value in the outer enumerable and Sum() them together
    4. Filter out nulls
    5. Select values
    6. Convert to List for return type

    {1,4,4,4,0,4,3,3,1} becomes:
    {1,12,null,null,0,4,6,null,1}