程序代写代做代考 go html interpreter CSSE 304 Exam 2 Part 3b 10/16/2018 (day 26.5) Name_____________________ Section (circle one): 01(9:00) 02 (9:55) 03 (10:50)

CSSE 304 Exam 2 Part 3b 10/16/2018 (day 26.5) Name_____________________ Section (circle one): 01(9:00) 02 (9:55) 03 (10:50)
Problem
Possible
Earned
Comments
C2
15
Unless you have an accommodation in writing, you may not use email, IM, cell phone, PDA, headphones, earbuds, or any other communication device or software.
interpreter enhancement You may use a Scheme editing/programming environment, CSSE 304 textbooks including TSPL, Chez Scheme Users’ Guide, PLC grading program, and any materials that I provided online for the course. You are allowed to look at and copy any Scheme code that you (or you and your partner) wrote before the exam, but nothing else that was written by others, including CSSE 304 students from previous terms. You may not use any other web or network resources.
C2. (15 points) In the Day 8 class, we discussed the case-lambda syntax (see the slides for details). You can also find information here: http://www.scheme.com/tspl4/binding.html#./binding:s13, which is also linked from the TSPL Summary of Forms).
Add case-lambda to your interpreter’s interpreted language. You can earn more than half of the points if your case-lambda only works when all of the argument lists are proper lists. For full credit, it should also work when argument lists are single symbols or improper lists.
No error checking is required; all of my test cases should contain correct code.
Thoughts based on my experience of solving this problem (you do not have to do what I did; these comments are to help jump-start
your thought process):
 I thought about it for a lot longer than you will have to think about it tonight, and I concluded that the simplest expression variant to use for case-lambda-exp has one field: a list of expressions (which all happen to be lambda expressions). You are free to disagree,
 I had the evaluation of a case-lambda produce a case-closure, which contains a list of ordinary closures.
 I wrote a match-args? helper predicate, which takes as arguments an integer n and the parameter-list pa-li from a
closure (regular ot improper). This predicate returns true if an argument list with n arguments is a match for pa-li.
 cases can have an else clause, so you only have to individually list the particular variants that you are actually using.
Some examples:
> (eval-one-exp ‘((case-lambda
[(n) (+ n 2)]
[(m n) (+ m n 10)])
5))
7
> (eval-one-exp
‘((case-lambda
[(n) (+ n 2)]
[(m n) (+ m n 10)])
5 8))
23
> (eval-one-exp
‘((case-lambda
[(n) (+ n 2)]
[(m . n) (+ m (car n) 10)])
5 8))
Help us to give you
appropriate (partial) credit
In each area of interpreter code that you add or change, put a comment that is something like the one below, to make it easy for us to find all of the parts that you added.
;;———————————————-
Feel free to put that comment at the end of a medium-length line of code, so it will stand out.
23

> (eval-one-exp ‘((case-lambda
[(m . n) (+ m (car n) 10)]
[(n) (+ n 2)])
5 8))
23
> (eval-one-exp
‘(let ([f (case-lambda
[(n) (+ n 2)]
[(m . n) (+ m (car n) 10)]
[L (list L)])])
(list (f)
(f 4)
(f 5 6)
(f 7 8 9)
)))
((()) 6 21 25) > (eval-one-exp
‘(let ([f (case-lambda
[(n) (+ n 2)]
[(m . n) (+ m (car n) 10)]
[L (list L)])])
(f (f 3 4 5))))
19
If you finish this part before finishing Part 3a, please go ahead and submit this one so we can get it graded. That will help us be able to get the exams graded in time to return them to you in Thursday’s class.
Submit this problem to the
E2-201910-Problem C1 (interpreter)
assignment on the PLC server.