(defun range (min max) (loop for n from min below (+ max 1) by 1 collect n)) (defun sum (list) (apply '+ list)) (defun select (expr list) (remove-if-not expr list)) (defun filter (expr list) (remove-if expr list)) (defun empty (list) (eq list nil)) (defun partial (func &rest args1) (lambda (&rest args2) (apply func (append args1 args2))) ) (defun prime (n) (eq (length (member T (mapcar (lambda (a) (and (eq (mod n a) 0) (/= n a))) (range 2 (sqrt n))))) 0) ) (defun cartesian-helper (thing list) (if (empty list) nil (cons (list thing (first list)) (cartesian-helper thing (rest list))) ) ) (defun cartesian (list-one list-two) (if (empty list-one) nil (append (cartesian-helper (first list-one) list-two) (cartesian (rest list-one) list-two)) ) ) (defun number-to-digit-list (num) (if (< num 10) (list num) (append (number-to-digit-list (floor (/ num 10))) (list (mod num 10))) ) ) (defun digit-list-to-number (digit-list) (if (empty digit-list) 0 (+ (* (first digit-list) (expt 10 (- (length digit-list) 1))) (digit-list-to-number (rest digit-list))) ) ) (defun is-palindrome (num) (let* ((digit-list (number-to-digit-list num))) (equal (reverse digit-list) digit-list)) ) (defun resolve-tuple (expr tuple) (funcall expr (first tuple) (second tuple)) ) (defun resolve-tuples (expr tuple-list) (mapcar (partial #'resolve-tuple expr) tuple-list) ) (defun max-of (list) (reduce #'max list) )