Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

post you are run length encoding in lisp

Name: Anonymous 2014-10-05 3:18

critique mine pl0x:

(defun rle (str) ;run length encoding
(let ((i 0) c count out)
(while (< i (length str))
(if (eq c (elt str i))
(setq count (1+ count))
(when c
(setq out (append out (list (cons c count)))))
(setq c (elt str i))
(setq count 1))
(setq i (1+ i)))
(when c (setq out (append out (list (cons c count)))))
out))

Name: Anonymous 2014-10-05 7:27

Yeah. I remember implementing it to read old graphic formats. Although LZ is a lot better
https://github.com/saniv/gfx/blob/master/pcx.lisp

(defun pcx-rle-line (o s e)
(while (< (cdr s) e)
(let ((v (% s))
(c 1))
(while (and (< (cdr s) e) (= (% 0 s) v) (< c 63))
(% s)
(incf c))
(unless (and (= c 1) (/= (logand #xC0 v) #xC0))
(ser o (Count 1 (logior #xC0 c))))
(ser o (Value 1 v)))))

(defun pcx-derle-line (o s e)
(while (< (cdr o) e)
(let ((c (% s)))
(if (/= (logand c #xC0) #xC0)
(% o c)
(let ((c (logxor c #xC0))
(v (% s)))
(while (plusp c)
(% o v)
(decf c)))))))

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List