Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
5
Task/Run-length-encoding/Racket/run-length-encoding.rkt
Normal file
5
Task/Run-length-encoding/Racket/run-length-encoding.rkt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#lang racket
|
||||
(define (encode str)
|
||||
(regexp-replace* #px"(.)\\1*" str (λ (m c) (~a (string-length m) c))))
|
||||
(define (decode str)
|
||||
(regexp-replace* #px"([0-9]+)(.)" str (λ (m n c) (make-string (string->number n) (string-ref c 0)))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue