;;Functions to help test-compression ;;The next three functions came from the text book, page 37, Figure 3.6 (defun compress (x) (if (consp x);if its a cons, call the helper function on the car, giving it a count of 1 and the cdr. (compr (car x) 1 (cdr x)) x));return x. (defun compr (elt n lst) (if (null lst); if the lst is null (list (n-elts elt n));create a list of (elt n) (let ((next (car lst)));else call next on the car of lst. (if (eql next elt) (compr elt (+ n 1) (cdr lst));if the elt and the next are eql, add 1 to count (cons (n-elts elt n);else, create a cons of (elt n) (compr next 1 (cdr lst)))))));and start with the next ans the elt with a count of 1 and the cdr of the list. (defun n-elts (elt n);if n is greater than 1, create a list of n and elt, else, return elt (if (> n 1) (list n elt) elt)) ;;The next two functions came from the text book, page 38, Figure 3.7 (defun uncompress (lst) (if (null lst);if the lst is mt, return nil nil (let ((elt (car lst));else, save the elt. (rest (uncompress (cdr lst))));uncompress the cdr of the lst, and store in rest. (if (consp elt);then, if elt is a cons cell (append (apply #'list-of elt);apply the list-of function to elt, and apply that to rest. rest) (cons elt rest))))); create a cons with elt and rest. (defun list-of (n elt) (if (zerop n); if n is 0, return nil nil (cons elt (list-of (- n 1) elt))));else, return a cons cell of elt followed by the list-of with elt and n - 1 ;Chapter 3, Test 2, Page 37 (deftest test-compression () (check (equal (list-of 4 `a) (list `a `a `a `a)) ;makes a list of 4 elements of a (not (eql (list-of 3 `a) (list `a `a `a)));makes a list of 3 elements of a, but its not eql. (equal (compress `(1 1 1 0 1 0 0 0 0 1)) (list (list 3 1) 0 1 (list 4 0) 1));compress an array (equal (uncompress `((3 1) 0 1 (4 0) 1)) (list 1 1 1 0 1 0 0 0 0 1))));uncompress said array.