Summary of the Problem Solving of SiC exercises (2.7): defining the data structure of intervals

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.