Answered step by step
Verified Expert Solution
Question
1 Approved Answer
solve this exercise and solution please Exercise 1 Make data structures using cons for the following 1. (hi . everybody) 2. (0) 3. ( 10.
solve this exercise and solution please
Exercise 1 Make data structures using cons for the following 1. ("hi" . "everybody") 2. (0) 3. ( 10. 100) 4. (1 10 100) (#1 "saw" 3 "girls") 6. ("Sum of" (1 2 3 4) "is" 10) quote All tokens are ready to be evaluated due to the Scheme's rule of the evaluation that tokens in parentheses are evaluated from inner to outer and that the value comes out from the outermost parentheses is the value of the S-expression. A special form named quote is used to protect tokens from evaluation. It is for giving symbols or lists to a program, which became something else by evaluation. For instance, while + 2 3) is evaluated to be 5, (quote (+ 2 3) gives a list + 2 3) itself to the program. As quote is frequently used, it is abbreviated as' For example: .2 3) represents a list 2 3) itself. represents a symbol itself. Actually, 'O is a quoted empty list, which means that you should write'O to represent an empty list while the interpreter responds 0 for an empty list. Special forms Scheme has two kinds of operators: One, functions. Functions evaluate all the arguments to return value. The other is special forms. Special forms do not evaluate all the arguments. Some example of special forms: quote, lambda, define, if, set! Functions car and cdr The functions that returns the car part and the cdr part of a cons cell is called car and cdr, respectively. If the value of cdr is beaded cons cells, the interpreter prints whole values of the car parts. If the cdr part of the last cons cell is not '0, the value is also shown after . (car '(1 2 3 4)) (cdr'(1 2 3 4)) (2 3 4) Exercise 1 Make data structures using cons for the following 1. ("hi" . "everybody") 2. (0) 3. ( 10. 100) 4. (1 10 100) (#1 "saw" 3 "girls") 6. ("Sum of" (1 2 3 4) "is" 10) quote All tokens are ready to be evaluated due to the Scheme's rule of the evaluation that tokens in parentheses are evaluated from inner to outer and that the value comes out from the outermost parentheses is the value of the S-expression. A special form named quote is used to protect tokens from evaluation. It is for giving symbols or lists to a program, which became something else by evaluation. For instance, while + 2 3) is evaluated to be 5, (quote (+ 2 3) gives a list + 2 3) itself to the program. As quote is frequently used, it is abbreviated as' For example: .2 3) represents a list 2 3) itself. represents a symbol itself. Actually, 'O is a quoted empty list, which means that you should write'O to represent an empty list while the interpreter responds 0 for an empty list. Special forms Scheme has two kinds of operators: One, functions. Functions evaluate all the arguments to return value. The other is special forms. Special forms do not evaluate all the arguments. Some example of special forms: quote, lambda, define, if, set! Functions car and cdr The functions that returns the car part and the cdr part of a cons cell is called car and cdr, respectively. If the value of cdr is beaded cons cells, the interpreter prints whole values of the car parts. If the cdr part of the last cons cell is not '0, the value is also shown after . (car '(1 2 3 4)) (cdr'(1 2 3 4)) (2 3 4)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started