1. (:-) 2a. c_keyword(X), X=break This will succeed with c_keyword, but will fail with c_keyword_x because it succeeds first with X=auto, and fails when backtracked into. 2b. c_keyword_x(X) :- c_keyword(X), !. 3. access_to_object(C, C2, [access|L], L2) :- general_access_modifier(C1, [*|C2], L, L1), nonarray_type(C, C1, L1, L2). accesss_to_object(C, C2, [access,all,id(float)], L2) 4a. 7 names: main function, struct main, main member (used three times), outer "main" variable (used once), enum value (used twice), label (used once), inner "main" variable (used three times). Exact uses left as an exercise for the reader. 4b. Identifiers declared inside begin-end braces are not visible outside, except for labels, whose scope are the containing function. There are multiple name spaces: ordinary names, labels, struct tags, and member names. Syntactic context determines which space a name belongs to, e.g., a name after "goto" or before ":" must be a label. Names in an inner scope shadow names from the same name space declared in an outer scope. 4c. In "struct main main = main;" the variable "main" is used without first being initialized. 5a. (define (map1bt f obj) (let mapit ((obj obj)) (cond ((pair? obj) (cons (mapit (car obj)) (mapit (cdr obj)))) ((null? obj) '()) (else (f obj))))) 5b. type 'a bt = Cons of 'a bt * 'a bt | Leaf of 'a option let map1bt f obj = let rec mapit = function | Cons (a, d) -> Cons (mapit a, mapit d) | Leaf None -> Leaf None | Leaf Some obj -> f obj in mapit obj 5c. (define (btmap procs obj) (map1bt (lambda (proc) (proc obj)) procs)) 5d. (define (btmapi procs obj) (mapibt (lambda (proc) (proc obj)) procs)) where mapibt is the solution to Homework 2. 5e. (define (maptrees tp to) (map1bt (lambda (f) (map1bt f to)) tp)) Here's another answer, which is not quite as nice: (define (maptrees tp to) (btmap (map1bt (lambda (f) (lambda (bt) (map1bt f bt))) tp) to))