#lang racket
; Exam 1. (100 points)
; The exam consists of four problems plus one extra credit problem.
; Each problem asks you to implement a procedure. You should
Copyright By PowCoder代写 加微信 powcoder
; implement and test your code in DrRacket. Submit your solutions via
; Blackboard.
; You may not discuss this exam with anyone other than Prof. Checkoway.
; You may refer to the lecture videos, lecture slides, readings, your
; notes, or the Racket standard library reference:
; https://docs.racket-lang.org/reference/pairs.html
; https://docs.racket-lang.org/reference/procedures.html
; (the second link is really only useful for the description of apply).
; You are free to use any of the procedures described in those
; references in your solutions, including, but not limited to, cons,
; car, cdr, first, second, rest, list, append, reverse, map, foldl,
; foldr, filter, remove, member, empty?, and apply, unless otherwise
; specified.
; Each of the problems comes with some examples. For your convenience,
; the examples are included in a test suite at the end of this file.
; Problem 1. (25 points)
; Write a recursive procedure (split-by pred lst) that takes a predicate
; pred–a predicate is just a 1-argument procedure that returns #t if it
; is satisfied, e.g., positive?, list?, and (λ (x) (> x 3)) are examples
; of predicates–and a list. (split-by pred lst) returns a 2-element list
; of lists. The elements x of lst for which (pred x) returns #f are put
; in the second list and everything else goes in the first list.
; For example,
; – (split-by positive? empty) => ‘(() ())
; – (split-by negative? ‘(0 -1 2 3 4 -5 -6 7 -2)) => ‘((-1 -5 -6 -2) (0 2 3 4 7))
; – (split-by (λ (x) x) ‘(1 “two” three #f #t ())) => ‘((1 “two” three #t ()) (#f))
; For this problem, you may not use the standard library partition
; function which is very similar. For full credit, you may only make a
; single pass over the input list lst. In particular, using several list
; procedures that go over the whole list (like length, map, filter,
; foldl, and foldr) will resul
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com