Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,27 @@
(defconstant +lower+ (coerce "abcdefghijklmnopqrstuvwxyz" 'list))
(defun move-to-front (x xs)
(cons x (remove x xs)))
(defun enc (text table)
(map 'list
(lambda (c)
(let ((idx (position c table)))
(setf table (move-to-front c table))
idx))
text))
(defun dec (indices table)
(coerce (mapcar (lambda (idx)
(let ((c (nth idx table)))
(setf table (move-to-front c table))
c))
indices)
'string))
(loop for word in '("broood" "bananaaa" "hiphophiphop")
do (let* ((encoded (enc word +lower+))
(decoded (dec encoded +lower+)))
(assert (string= word decoded))
(format T "~s encodes to ~a which decodes back to ~s.~%"
word encoded decoded)))