Racket代写 | CIS 352 Quiz0 and Quiz1 / Sample questions

本次美国代写主要为Racket相关的限时测试

Question Format
Objective #N [ do not title questions, it makes it even easier for students to collude ]
[potential code / diagram / figure that will be referenced in the question]
Satisfactory:
[problem description that outlines what the student must answer to be marked as
satisfactory. Note that small mistakes (e.g., typos such as 1-2 misplaced
parentheses where the TA can understand what the student meant without spending
>60seconds) are okay if they do not compromise the essence of the answer.]
Excellent:
[an add-on to the satisfactory problem, usually a bit harder, that the student must
perform to get this question right. Note that they can only get the excellent mark if
they both get a good solution and also have a nearly-100% correct answer to the
satisfactory part]
Objective #1: “Identify expressions, forms, and callsites (in
Racket)”
Question 1Sample
Satisfactory:
Both A-B required for satisfactory

How many callsites does the following piece of Racket code contain:
(define (foo) (bar (baz)))
(define (bar x) (baz))
(define (baz) (+ 1 (bar x)))
Explain why the following Racket expression prints 3 rather than 1.
(let ([x 3]) (let ([x 1] [y x]) y))
Excellent:
A student believes that one of the guards to their if forms is incorrect, so they
define the following helper function:
(define (if guard e-true e-false)
(displayln (format “guard is ~a” guard))
(if guard e-true e-false))
Aside from printing to the console, are there any other ways in which defining
this helper function may change the behavior of the program? Give a precise
explanation (with example code, if possible) of how this may happen.

Comments:Question 1A
Satisfactory:
Both A-B required for satisfactory
(A)How many callsites does the following Racket expression contain?
(g (f ((lambda (x) x) 2))1)2 3

(B) Consider the following Racket expression using let*:
(let ([x (let* ([x 1] [y x]) y)]) x)
How could this expression be written without let* (using only let). For your
solution to receive credit, it must still include bindings for each of x and y within
the top-level let (i.e., your answer may not simply be `1`).
(let ([x (let ([x 1]) (let ([y x])) y)]) x)
(let* ([x 1]
[y …])
…)
(let ([x 1]) (let ([y …]) …)…)
Excellent:
In class, we have discussed that or is not a Racket function, but rather it is a
form. In general, for arbitrary expressions e-first and e-second the following two
Racket snippets are not identical (in the sense that you could replace one with
the other).
(define (loop) (loop))
(if #t #t (loop)) ;; #t
(if #t #t (loop)) ;; #t
((lambda (x y) (if x x y)) #t (loop)) ;; function call to (lambda (x y) …)