From 7b7bf727da3250907284368b98b0083a4b4e2386 Mon Sep 17 00:00:00 2001 From: mryouse Date: Sat, 3 Jun 2023 20:22:18 +0000 Subject: initial commit --- p99/p11.neb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 p99/p11.neb (limited to 'p99/p11.neb') diff --git a/p99/p11.neb b/p99/p11.neb new file mode 100644 index 0000000..546a7c2 --- /dev/null +++ b/p99/p11.neb @@ -0,0 +1,25 @@ +; P11 (*) Modified run-length encoding. +; Modify the result of problem P10 in such a way that if an element has +; no duplicates it is simply copied into the result list. Only elements +; with duplicates are transferred as (N E) lists. + +(use "p10.neb") + +(func encode-modified (lst) + (map + (lambda (item) + (if (eq? 1 (length item)) + (first item) + (list (length item) (first item)))) + lst)) + +(func encode-squish (lst) + (map + (lambda (item) + (if (eq? 1 (first item)) + (last item) + item)) + lst)) + +(print (concat "from result of P09: " (->string (encode-modified (pack-dup a))))) +(print (concat "from result of P10: " (->string (encode-squish (encode (pack-dup a)))))) -- cgit v1.2.3