implemented modified run-length encoding of a list (P11)