Deliverable: submit two files: your source code, and a transcript showing the code in operation.
(range 3 6) => (3 4 5 6) (range 4 4) => (4) (range 10 0) => ()Write a version of range in the Continuation Passing Style. For example
(range 3 6 print)should cause the list (3 4 5 6) to be printed (where "print" above is the continuation argument).
(intersect '(1 2 3 4) '(3 4 5) '(1 2 3 4 5 6)) => (3 4) (intersect '(1 2 3)) => (1 2 3) (intersect '(1 2 3 4) '(3 4 5) '() '(1 2 3 4 5 6)) => () (intersect) => error procedure intersect: expects at least 1 argument, given 0Hints: you can assume that the lists represent proper sets (no duplicate elements). You shouldn't write any error handling code for the case of feeding 0 arguments to intersect -- just write your function to expect at least one argument. You can have a helper function intersect2 that intersects two sets (which you might copy from HW 6 and rename).
Hint: study the list-product example from the lecture notes, which does a similar escape if it detects a 0 in the list of numbers being multiplied. You can put in extra print statements to show that indeed you are escaping without doing any intersecting if you encounter an empty set. (This is optional but recommended.)
(map f lst k)This function should apply f to every element of the list lst, and feed the result to the continuation k. But wait! There's more. Just to make life interesting, f itself is also written in the Continuation Passing Style.