As an extended exercise, exercise 2.7 does not affect subsequent learning. However, if you can understand the process above and the Qiqi count, it is no problem to complete these extended exercises.
Exercise 2.7 requires us to assist allysa in defining interval.
Allysa defines the following process to create an interval (interval), where A is the starting point (that is, a smaller part), and B is the ending point (that is, a larger part ).
(define (make-interval a b) (cons a b))
We need to implement the lower-bound process and upper-bound process to obtain the start and end points of a range.
Since the start and end points are connected by the cons function, it is easy to get the start and end functions. You can get them through car And CDR:
(define (lower-bound x) (car x))(define (upper-bound x) (cdr x))
It is worth noting that such a simple method of building Composite data continues to emerge in the chapters that follow this book, turning it into a conventional means of data organization, so you can pay more attention to this series of extended exercises to enhance your understanding of composite data.
Summary of the Problem Solving of SiC exercises (2.7): defining the data structure of intervals