---------------------------------------------------------------------- 1. One person asked for output of Assignment 3. I include it below. Note, however, that the first three inconsistencies have been fixed in the new policy files for Assignment 4. total number of predicates: 56 RA-manager-regs: 2 Register-team-member: 3 Register-ward-member: 3 agent-regs: 2 canActivate: 2 canActivated: 2 canDeactivate: 3 canDeactivate: 2 canDectivate: 3 canReqCred: 2 cg-regs: 2 clinician-regs: 3 count-PDS-manager-activations: 2 count-agent-activations: 2 count-authenticated-express-consent: 2 count-caldicott-guardian-activations: 2 count-clinician-activations: 2 count-conceal-requests: 2 count-concealed-by-clinician: 3 count-concealed-by-patient: 2 count-concealed-by-patient2: 3 count-concealed-by-spine-clinician: 3 count-concealed-by-spine-patient: 3 count-ext-treating-clinician-activations: 2 count-hr-mgr-activations: 2 count-patient-activations: 2 count-preofessional-user-activations: 2 count-professional-user-activations: 2 count-receptionist-activations: 2 count-spine-admin-activations: 2 count-spine-clinician-activations: 2 count-third-party-activations: 2 hasActivated: 2 head-of-team-regs: 3 head-of-ward-regs: 3 hr-manager-regs: 2 is-emergency-clinician: 2 isDeactivated: 3 isDeactivated: 2 no-main-role-active: 1 other-NHS-health-org-regs: 5 other-agent-regs: 4 other-consent-to-group-treatment-requests: 5 other-consent-to-group-treatment-requests: 6 other-consent-to-referral-requests: 7 other-consent-to-treatment-requests: 6 other-referral-consents: 7 other-third-party-consent-requests: 3 other-third-party-requests: 3 patient-regs: 2 pds-admin-regs: 2 permits: 2 receptionist-regs: 2 spine-admin-regs: 2 team-episode-regs: 3 team-member-regs: 4 third-party-consent: 3 ward-episode-regs: 3 ward-member-regs: 4 other-consent-to-group-treatment-requests: arity 5 occurs 1 times, arity 6 occurs 1 times (S2.4.12) other-consent-to-group-treatment-requests(n,y,pat,org,group) (S2.4.8) other-consent-to-group-treatment-requests(count,x,pat,org,cli,spcty) canDeactivate: arity 2 occurs 3 times, arity 3 occurs 94 times (S2.1.4) canDeactivate(pat,One-off-consent(pat)) (S2.1.5) canDeactivate(ag,One-off-consent(pat)) (S2.1.6) canDeactivate(cli,One-off-consent(pat)) isDeactivated: arity 2 occurs 101 times, arity 3 occurs 1 times (S3.1.4) isDeactivated(pat,cli1,Referrer(pat,org,cli2,spcty1)) total number of constructors: 69 ADB-treating-clinician: 3 Add-record-item: 1 Add-spine-record-item: 1 Agent: 1 Annotate-record-item: 2 Annotate-spine-record-item: 2 Authenticated-express-consent: 2 Caldicott-guardian: 0 Clinician: 1 Conceal-request: 4 Conceal-request: 1 Concealed-by-clinician: 4 Concealed-by-patient: 4 Concealed-by-patient: 1 Concealed-by-spine-clinician: 4 Concealed-by-spine-patient: 4 Consent-to-group-treatment: 3 Consent-to-referral: 5 Consent-to-treatment: 4 Emergency-clinician: 1 Ext-treating-clinician: 4 Force-read-record-item: 2 Force-read-spine-record-item: 2 General-practitioner: 1 Get-record-item-ids: 1 Get-spine-record-item-ids: 1 Group-treating-clinician: 5 HR-mgr: 0 Head-of-team: 1 Head-of-ward: 1 NHS-Caldicott-guardian-cert: 4 NHS-clinician-cert: 5 NHS-health-org-cert: 3 NHS-registration-authority: 3 NHS-service: 0 One-off-consent: 1 PDS-manager: 0 Patient: 0 Professional-user: 2 RA-manager: 0 Read-record-item: 2 Read-spine-record-item: 2 Receptionist: 0 Referrer: 4 Register-Caldicott-guardian: 1 Register-HR-mgr: 1 Register-PDS-manager: 1 Register-RA-manager: 1 Register-agent: 2 Register-clinician: 2 Register-head-of-team: 2 Register-head-of-ward: 2 Register-patient: 1 Register-receptionist: 1 Register-spine-admin: 1 Register-team-episode: 2 Register-team-member: 3 Register-ward-episode: 2 Register-ward-member: 3 Registration-authority: 0 Request-consent-to-group-treatment: 3 Request-consent-to-referral: 5 Request-consent-to-treatment: 4 Request-third-party-consent: 3 Spine-admin: 0 Spine-clinician: 3 Spine-emergency-clinician: 2 Third-party: 0 Third-party-consent: 3 Treating-clinician: 3 Workgroup-member: 3 Concealed-by-patient: arity 1 occurs 1 times, arity 4 occurs 7 times (A4.2.7) Concealed-by-patient(y) Conceal-request: arity 1 occurs 1 times, arity 4 occurs 8 times (S4.2.7) Conceal-request(y) ---------------------------------------------------------------------- 2. One person asked for books or tutorials for writing comprehensions and recursion. I don't have good ones in the sense that they are good for Assignment 4. They are many bigs book and articles that it will take much more time for us to find what we want from them than trying to write the solutions ourselves. For comprehensions, besides those seen in classes and in the Python tutorial, you can see my solutions to Assignment 2 that are given in the handout for Assignment 4. For recursive functions, below are some more examples besides what we discuss in classes. The first sort (sort1 with insert) does an insertion sort: sort the tail and then insert the head in an appropriate place in the sorted tail. The second sort (sort2 with least and rest) does a selection sort: selecting the minimum and then recursively sort the rest. The squares and cubes using map are much more succinct than squares2 and similar ones. def sort1(l): if null(l): return nil() else: return insert(car(l),sort1(cdr(l))) def insert(x,l): if null(l): return cons(x,nil()) elif x<=car(l): return cons(x,l) else: return cons(car(l),insert(x,cdr(l))) def sort2(l): if null(l): return nil() else: x = least(l) return cons(x,sort2(rest(l,x))) def least(l): if null(cdr(l)): return car(l) else: x = least(cdr(l)) return car(l) if car(l)<=x else x def rest(l,x): if x==car(l): return cdr(l) else: return cons(car(l),rest(cdr(l),x)) def map(f,l): if null(l): return nil() else: return cons(f(car(l)),map(f,cdr(l))) def squares(l): return map(lambda x:x*x,l) def cubes(l): return map(lambda x:x*x*x,l) def squares2(l): if null(l): return nil() else: return cons(car(l)*car(l),squares2(cdr(l))) ----------------------------------------------------------------------