;;; PREDICATES 4: EQL AND EQUALP ;;; ;;; The ladder has two rungs exercise 2 left unclimbed: ;;; ;;; EQL same object, or the same number or character - same type ;;; too: (eql 1 1.0) is NIL. ;;; EQUALP the generous one: numbers by value - (equalp 1 1.0) is ;;; T - characters ignoring case. ;;; A character is written #\a - and #\A is another one. ;;; ;;; Fix each definition with the comparison its comment names. ;; TODO: EQL - the very same number, 1 and 1.0 disagree. (defun same-exact-p (a b) (= a b)) ;; TODO: EQUALP - the same amount, 1 and 1.0 agree. (defun same-amount-p (a b) (eql a b)) ;; TODO: EQUALP - the same letter, case ignored. (defun same-twin-p (a b) (equal a b)) ;;; ------------------------------------------------------------------ ;;; Checks. Read them - they tell you what to aim for - but leave ;;; them unchanged. ;;; ------------------------------------------------------------------ (check (same-exact-p 7 7)) (check (not (same-exact-p 1 1.0))) (check (not (same-exact-p 1 2))) (check (same-amount-p 1 1.0)) (check (not (same-amount-p 1 2))) (check (same-twin-p #\a #\A)) (check (not (same-twin-p #\a #\b)))