run-length encoding of a list