正在加载图片...
Your task is to add this special form to m-eval, showing your changes to the code, and demonstrating that it works by providing some test cases Caveat: avoid mutation on the expression that you are desugaring; for example, when the expression which you are passed is the code pointer of a compound expression, mutating the expression will actually change what the procedure does To do this, you should include the followin Create a data abstraction for handling do. while loops, that is, selectors for getting out the parts of the loop that will be needed in the evaluation Add a dispatch clause to the right part of m-eval. We have actu included this clause, you simply need to uncomment it. Write the procedure(s) that handle the actual evaluation of the hile loop Be sure to turn in a listing of your additions and changes, as well as examples of your code working on test cases Computer Exercise 4: The let* special form. low let's try something a bit tougher. We have already seen the let special form. A variation on this is the let* special form. This form acts much like let however, the clauses of the let* are evaluated in order (rather than all at the same time as in a let), and any reference in a later clause to the variable of an earlier clause should use the new value of that variable. For example (define i 1) (1et((i3) (i (factorial i)) (11stij))) would return the value(3 1) because the let variables i, j are bound in parallel, and thus the argument to fact is the value of i outside the expression namely 1. on the other hand (define i 1 (1et*((i3) (i(factorial 1)) (list i 3))) would return the value (3 6) since the variable i is first bound to 3, and then the variable j is bound, and in this case the input to fact is the new value 3Your task is to add this special form to m-eval, showing your changes to the code, and demonstrating that it works by providing some test cases. Caveat: avoid mutation on the expression that you are desugaring; for example, when the expression which you are passed is the code pointer of a compound expression, mutating the expression will actually change what the procedure does. To do this, you should include the following: • Create a data abstraction for handling do...while loops, that is, selectors for getting out the parts of the loop that will be needed in the evaluation. • Add a dispatch clause to the right part of m-eval. We have actually included this clause, you simply need to uncomment it. • Write the procedure(s) that handle the actual evaluation of the do...while loop. Be sure to turn in a listing of your additions and changes, as well as examples of your code working on test cases. Computer Exercise 4: The let* special form. Now let's try something a bit tougher. We have already seen the let special form. A variation on this is the let* special form. This form acts much like let, however, the clauses of the let* are evaluated in order (rather than all at the same time as in a let), and any reference in a later clause to the variable of an earlier clause should use the new value of that variable. For example (define i 1) (let ((i 3) (j (factorial i)) (list i j))) would return the value (3 1) because the let variables i, j are bound in parallel, and thus the argument to fact is the value of i outside the expression, namely 1. On the other hand: (define i 1) (let* ((i 3) (j (factorial i)) (list i j))) would return the value (3 6) since the variable i is first bound to 3, and then the variable j is bound, and in this case the input to fact is the new value 3
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有