Complete up to exercise 4.56

This commit is contained in:
Oliver Payne 2024-04-03 23:11:09 +01:00
parent 911dc3512d
commit 3978de8110
1 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,30 @@
#lang sicp
;; Exercise 4.55
;; Everyone supervised by Ben
(supervisor ?x (Bitdiddle Ben))
;; Everyone in the accounting division
(job ?x (accounting . ?y))
;; Everyone who lives in Slumerville
(address ?x (Slumerville . ?y))
;; Exercise 4.56
;; Names and addresses of everyone supervised by Ben Bitdiddle
(and (address ?person ?address)
(supervisor ?person (Bitdiddle Ben)))
;; All people whose salaray is less than Ben Bitdiddle's together with
;; their salary and Ben's salary
(and (salary ?person ?amount)
(and (salary (Bitdiddle Ben) ?ben-salary)
(lisp-value < ?amount ?ben-salary)))
;; All people who are supervised by someone who is not in the computer
;; division, together with the supervisor's name and job.
(and (supervisor ?person ?supervisor)
(job ?supervisor ?supervisor-job)
(not (job ?supervisor (computer . ?x))))