;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This file is part of AIslash. ; ; AIslash is free software: you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation, either version 3 of the License, or ; (at your option) any later version. ; ; AIslash is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with AIslash. If not, see . ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmethod discrete! ((d discrete)) d) (defmethod discrete! ((n numeric)) (let ((d (make-discrete :name (numeric-name n) :classp (numeric-classp n) :ignorep (numeric-ignorep n) :pos (numeric-pos n)))) (dolist (one (numeric-all n)) (sniff d one)) (taste d) d)) (defun symbolize-rows (headers rows 4class 4others) (mapcar #'(lambda (row) (symbolize-row headers row 4class 4others)) rows)) (defun symbolize-row (headers row 4class 4others) (mapcar #'(lambda (header cell) (symbolize-cell header cell 4class 4others)) headers row)) (defmethod symbolize-cell ((n numeric) x 4class 4others) (if (header-classp n) (funcall 4class n x) (funcall 4others n x))) (defmethod symbolize-cell ((d discrete) thing f1 f2) (declare (ignore f1 f2)) (thing->sym d thing)) (defmethod thing->sym ((d discrete) thing) (cdr (assoc thing (discrete-ranks d)))) (defmethod sym->thing (d sym) (car (rassoc sym (discrete-ranks d)))) (defun thing->ewd (n thing) (floor (/ (- thing (numeric-min n)) (/ (- (numeric-max n) (numeric-min n)) (numeric-bins n))))) (defun ewd->thing (n ewd) (let ((width (- (numeric-max n) (numeric-min n)))) (+ (numerc-min n) (* width (+ 0.5 ewd))))) (defun thing->bore (n thing) (if (< (numeric-best n) 0) (if (<= thing (numeric-best-num n)) 1 0) (if (>= thing (numeric-best-num n)) 1 0))) (defun bore->thing (n bore) (let ((num1 (* 0.5 (- (numeric-best n) (numeric-min n)))) (num2 (* 0.5 (- (numeric-max n) (numeric-best n))))) (if (< (numeric-best n) 0) (if (zerop bore) num2 num1) (if (zerop bore) num1 num2))))