add reduce (foldLeft) implementation.
add countBy.