Use if let syntax for groupBy and countBy

This uses more idiomatic if let syntax to bind the optional dictionary lookup if it succeeds.
Unused array variable removed from groupBy.