Run-length encode a list