blob: 25ea1dc088b743d4da11a3772c382ef856f237de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
; P10 Run-length encoding of a list.
; Use the result of problem P09 to implement the so-called run-length
; encoding data compression method. Consecutive duplicates of elements
; are encoded as arrays [N, E] where N is the number of duplicates of the
; element E.
(use "p09.neb") ; NOTE: this runs everything at this juncture, not just def/func
(func encode (lst)
(map
(lambda (item)
(list (length item) (first item)))
lst))
(print (->string (encode (pack-dup a))))
|