Exercise 4.62. Define rules to implement the last-pair operation of exercise 2.17, which returns a list containing the last element of a nonempty list. Check your rules on queries such as (last-pair (3) ?x), (last-pair (1 2 3) ?x), and (last-pair (2 ?x) (3)). Do your rules work correctly on queries such as (last-pair ?x (3)) ? ———————————————————————————————————————————————————————————————————————— Exercise 2.17. Define a procedure last-pair that returns the list that contains only the last element of a given (nonempty) list: (last-pair (list 23 72 149 34)) (34) ———————————————————————————————————————————————————————————————————————— ; rule for singleton lists: (rule (last-pair (?x) (?x))) ; lists length ≥ 2 (rule (last-pair (?x . ?y) (last-pair ?y))) Untested, but they look like they might work. (Making a few assumptions about how these things are actually evaluated.)