This assignment asks you to write recursive procedures in Racket. The primary goal of this assignment is to gain experience with recursion and Racket lists. For this assignment:
Name your file of solutions homework04.rkt. The first three non-comment lines in your file should be:
#lang racket (require rackunit) (provide the names of your five solution procedures)
The first declares that you are using the Racket language. The second enables you to use rackunit to test your solutions [ example code ]. The third exports your procedures so that I can test them using my own rackunit tests.
For each of solutions, include at least five check-equal? expressions that test it for correctness. Put your tests immediately after the procedures for the problem:
; main procedure ; helper procedures ; test expressions
> (symbol* 's 2) '(s s) > (symbol* 'ew 5) '(ew ew ew ew ew) > (symbol* 'seattle 0) '()
> (take 2 '(a b c d e)) '(a b) > (take 5 (sequence 1 30)) '(1 2 3 4 5) > (take 10 '(a b c d e)) '(a b c d e)
> (positions-of 'a '(a b a c d a e f g a h i j k)) '(0 2 5 9) > (positions-of 'a '(b c d e f g h i j k)) '()
> (select positive? '(1 -1 2 -2 3 -3 4 -4 -5)) '(1 2 3 4) > (select boolean? (list 1 'a 't #t "false" #f '(a . b))) '(#t #f) > (select number? (list 'a 't #t '(1 2 3) "false" #f '(a . b))) '() > (select pair? (list 'a 't #t '(1 2 3) "false" #f '(a . b))) '((1 2 3) (a . b)) > (select (lambda (n) (> n 1008)) (sequence 1000 1010)) '(1009 1010)
> (any? #t) #t > (any? #f) #f > (any? #f #f #f #t #f #f) #t > (apply any? (map even? (sequence 1 30))) #t > (any?) #f
Hint: Make any? an interface procedure that calls a helper to do the real work with a single list argument.
By the due time and date, submit the following files:
Be sure that your submission follows all of the homework submission requirements. This includes: