approx-alike bug



For now I plan to fix the bug and clean up the code somewhat. Equality of the CRE expressions is done by converting to general form.
This means that a test such as

  taylor(0,x,0,12);
  0$

will pass--this is the way the testing code worked before I re-wrote it (previously the testing code tried various checks including string
equality of the grind form). 

Both Richard Fateman and Stavros helped me clean up the code. Additional suggestions are welcomed.
 
--Barton

(defun approx-alike (f g)
  (cond ((floatp f) (and (floatp g) ($float_approx_equal f g)))
    (($bfloatp f) (and ($bfloatp g) ($bfloat_approx_equal f g)))
    (($ratp f) (approx-alike g (ratdisrep f)))
    (($ratp g) (approx-alike g f))
    ((atom f) (and (atom g) (equal f g)))
    ;; allow a test such as sign(z); 'pnz$ to pass
    ((and (eq  'mquote (mop f)) (not (and (consp g) (consp (car g)) (eq 'mquote (mop g)))))
     (approx-alike (second f) g))
    ((atom g) (equal f g))
    ((eq 'lambda (mop f))
     (and (eq 'lambda (mop g))
          (approx-alike-list (mapcar #'(lambda (s) (simplifya s nil)) (margs f))
                 (mapcar #'(lambda (s) (simplifya s nil)) (margs g)))))
    ((arrayp f)
     (and (arrayp g) (approx-alike ($listarray f) ($listarray g))))
    ((hash-table-p f)
     (and (hash-table-p g) (approx-alike ($listarray f) ($listarray g))))
    ((and (eq (not (memq 'array (car f))) (not (memq 'array (car g))))
          (or (approx-alike (mop f) (mop g))
          (and (symbolp (mop f)) (symbolp (mop g)) (approx-alike ($nounify (mop f)) ($nounify (mop g))))))
     (approx-alike-list (margs f) (margs g)))
    (t nil)))