Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
10
Task/Run-length-encoding/Emacs-Lisp/run-length-encoding-1.l
Normal file
10
Task/Run-length-encoding/Emacs-Lisp/run-length-encoding-1.l
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
(defun run-length-encode (str)
|
||||
(let (output)
|
||||
(with-temp-buffer
|
||||
(insert str)
|
||||
(goto-char (point-min))
|
||||
(while (not (eobp))
|
||||
(let* ((char (char-after (point)))
|
||||
(count (skip-chars-forward (string char))))
|
||||
(push (format "%d%c" count char) output))))
|
||||
(mapconcat #'identity (nreverse output) "")))
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
(require 'seq)
|
||||
|
||||
(defun run-length-encode (str)
|
||||
(let ((grouped (mapcar #'cdr (seq-group-by #'identity (string-to-list str)))))
|
||||
(apply #'concat (mapcar (lambda (items)
|
||||
(format "%d%c" (length items) (car items)))
|
||||
grouped))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue