Hi all,

Someone of you could, please explain me, which kind of alteration, or calculus this function performs?

```
object SequenceCounter {
val ascending = SequenceCounter((left: Char, right: Char) => right == left + 1)
val constant = SequenceCounter((left: Char, right: Char) => right == left)
val descending = SequenceCounter((left: Char, right: Char) => right == left - 1)
}
case class SequenceCounter(
isSequence: (Char, Char) => Boolean,
maximum: Int = 1,
partial: Int = 1,
last: Char = 0
) {
def count(input: String): Int =
if (input == null || input == "NULL" || input.isEmpty)
0
else {
def map(accumulator: SequenceCounter, value: Char): SequenceCounter =
if (!isSequence(accumulator.last, value))
accumulator.copy(
partial = 1,
last = value
)
else
accumulator.copy(
maximum = Math.max(accumulator.maximum, accumulator.partial + 1),
partial = accumulator.partial + 1,
last = value
)
def reduce(left: SequenceCounter, right: SequenceCounter): SequenceCounter =
copy(maximum = Math.max(left.maximum, right.maximum))
input
.toCharArray
.aggregate(this)(map, reduce)
.maximum
}
}
```

Thank you !