(defun dojo-common-math-nil-aware-min (&rest args) (let ((result nil)) (dolist (arg args) (if (null result) (setq result arg) (if (not (null arg)) (setq result (min result arg))))) result)) (defun dojo-common-math-nil-aware-max (&rest args) (let ((result nil)) (dolist (arg args) (if (null result) (setq result arg) (if (not (null arg)) (setq result (max result arg))))) result)) (defun dojo-common-math-min-with-identifier (&rest args) "Given a list of identifier/value lists, this function returns a list (identifier, value) with the biggest value. The structure of the input list is ((identifier1, value1), ..., (identifierN, valueN))." (let ((result nil)) (dolist (arg args) (if (and (not (null arg)) (not (null (nth 1 arg))) (or (null result) (< (nth 1 arg) (nth 1 result)))) (setq result arg))) result) ) (defun dojo-common-math-max-with-identifier (&rest args) "Given a list of identifier/value lists, this function returns a list (identifier, value) with the biggest value. The structure of the input list is ((identifier1, value1), ..., (identifierN, valueN))." (let ((result nil)) (dolist (arg args) (if (and (not (null arg)) (not (null (nth 1 arg))) (or (null result) (> (nth 1 arg) (nth 1 result)))) (setq result arg))) result) ) (defun dojo-common-math-char-table-max-with-identifier (char-table) (let ((result nil)) (map-char-table #'(lambda (key value) (if (and (not (null value)) (or (null result) (> value (nth 1 result)))) (setq result (list key value)))) char-table) result)) (defun dojo-common-math-dec-char-table-entry (char-table key) (set-char-table-range char-table key (1- (char-table-range char-table key)))) (defun dojo-common-math-inc-char-table-entry (char-table key) (set-char-table-range char-table key (1+ (char-table-range char-table key)))) (defun dojo-common-math-add-to-char-table-entry (char-table key offset) (set-char-table-range char-table key (+ (char-table-range char-table key) offset))) (provide 'dojo-common-math)