From 7b7bf727da3250907284368b98b0083a4b4e2386 Mon Sep 17 00:00:00 2001 From: mryouse Date: Sat, 3 Jun 2023 20:22:18 +0000 Subject: initial commit --- p99/p10.neb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 p99/p10.neb (limited to 'p99/p10.neb') 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)))) -- cgit v1.2.3