CS FUNCTION
Q.1) Complete the function (nearest -even target L) . it consumes a Num and a (list of Int).
Of all the items in L that are even , it returns the one that has the smallest distance to target
In the case of a tie , pick the value closer to the left in the list .
For example , if the target is 15 , the distance between 12 and 15 is 3, and the distance between 22 and 15 is 7 , So considering 12 and 22 , the number with the smaller distance to 15 is 12 ,
So ( nearest-even 15 ( list 12 15 17 19 22)) => 12.
The distance between 15 and 17 is only 2 , but since 17 is odd , we do not consider it.
You may write as much of the design recipe as you like . Only your code will be marked .
;; (nearest-even target L) Return the even value in L that is closest to target.
;; nearest-even: Num (listof Int) -> Int
;; Requires: there is at least one even value in L.
;(define (nearest-even target L)
Hint: You may use the function abs to calculate absolute value
Q.2) Read the function (trace-me) and fill in the blanks:
;; (a) * The type of base must be: ……..
;; * Choose any appropriate value for base.
;(define base ……..)
;; (b) Given that this is a valid call to trace-me,
;; (trace-me (list 2 3 5))
;; * Write the contract for trace-me.
;; ……..
;(define (trace-me L)
; (string-append
; “*”
; (foldr G base L)))
;; (c) Write the contract for G.
;; ……..
;; (d) Trace the expression below as far as possible.
;; Image that G is defined, but do not expand any call to G.
;; A correct final result will get full marks.
;; You may include intermediate steps.
;; (trace-me (list 2 3 5))
;; => ……..