aboutsummaryrefslogtreecommitdiff
path: root/p99/p10.neb
diff options
context:
space:
mode:
Diffstat (limited to 'p99/p10.neb')
-rw-r--r--p99/p10.neb15
1 files changed, 15 insertions, 0 deletions
diff --git a/p99/p10.neb b/p99/p10.neb
new file mode 100644
index 0000000..25ea1dc
--- /dev/null
+++ b/p99/p10.neb
@@ -0,0 +1,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))))