;This code made by: Peotr Wojciec (defun eucliddist (row1 row2 &optional (fss (thecols)) (tbl (thetable))) (dist (mapcar (selectcols fss) (row-cells row1) (row-cells row2) (table-cols tbl)))) (defun euclidtest (n m) (eucliddist (nth n (therows)) (nth m (therows)))) (defun dist (lst) (let ((r^2 0)) (dolist (x lst (sqrt r^2)) (incf r^2 (* x x))))) (defun selectcols (fss) (lambda (el1 el2 coll) (if (memberp coll fss) (coldist el1 el2 coll) 0))) (defmethod coldist (el1 el2 (coll sym)) (cond ((col-goalp coll) 0) ((unknownp el1) 0) ((unknownp el2) 0) ((eql el1 el2) 0) (t 1))) (defmethod coldist (el1 el2 (coll num)) (cond ((col-goalp coll) 0) ((unknownp el1) 0) ((unknownp el2) 0) (t (- (normalized el1 coll) (normalized el2 coll))))) (defun normalized (el coll) (/ (- el (num-min coll)) (- (num-max coll) (num-min coll)))) (defun unknownp (cell) (eql cell #\?))