; 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))))))