<< Previous exercise (4.56) | Index | Next exercise (4.58) >>
(a) (assert! (rule (replace ?person1 ?person2) (and (job ?person1 ?job1) (job ?person2 ?job2) (or (same ?job1 ?job2) (can-do-job ?job1 ?job2)) (not (same ?person1 ?person2))))) (b) ;;; Query input: (replace ?p (Fect Cy D)) ;;; Query output: (replace (Bitdiddle Ben) (Fect Cy D)) (replace (Hacker Alyssa P) (Fect Cy D)) (c) (and (salary ?p1 ?a1) (salary ?p2 ?a2) (replace ?p1 ?p2) (lisp-value > ?a2 ?a1)) ;;; Query output: (and (salary (Aull DeWitt) 25000) (salary (Warbucks Oliver) 150000) (replace (Aull DeWitt) (Warbucks Oliver)) (lisp-value > 150000 25000)) (and (salary (Fect Cy D) 35000) (salary (Hacker Alyssa P) 40000) (replace (Fect Cy D) (Hacker Alyssa P)) (lisp-value > 40000 35000))
one not using positive same: