Jump to content

Run-length encoding: Difference between revisions

Emacs Lisp: Count first, then character
(Emacs Lisp: Completely rewrite solutions to something readable)
(Emacs Lisp: Count first, then character)
Line 2,294:
(let* ((char (char-after (point)))
(count (skip-chars-forward (string char))))
(push (format "%c%d%c" char count char) output))))
(mapconcat #'identity (nreverse output) "")))</lang>
 
Line 2,303:
(let ((grouped (mapcar #'cdr (seq-group-by #'identity (string-to-list str)))))
(apply #'concat (mapcar (lambda (items)
(format "%c%d%c" (carlength items) (lengthcar items)))
grouped))))</lang>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.