labs/L06
inside your ~/cs2613
git repositoryForm a group of 2 or 3.
Work together to design the template in FICS Exercise 17
Individually implement the function keep-first
which follows this
template.
Compare your functions. Are there any interesting differences?
Here is a test case
(check-expect (keep-first (list 1 2 3 4) 3) (list 1 2 3))
If that isn't enough for complete coverage for your solutions, add additional test cases.
Recall the template for structural recursion on two lists
(define (my-list-fn lst1 lst2)
(cond
[(empty? lst1) ... lst2 ...]
[(empty? lst2) ... lst1 ...]
[(cons? lst1)
... (first lst1) ... (first lst2) ...
... (my-list-fn (rest lst1) lst2) ...
... (my-list-fn lst1 (rest lst2)) ...
... (my-list-fn (rest lst1) (rest lst2)) ...]))
Use this template to complete FICS Exercise
20
You may find it helpful to refer to the function o-union
defined in
Section
5.4.
Note that the fact that the lists are sorted is key an efficient
solution here; you do not have to check that property.
Here are some test cases for the function intersection
(check-expect (intersection (list 1 2 3 4 5) (list 2 4 6 7))
(list 2 4))
(check-expect (intersection (list 2 4 11) (list 1 2 3 4 5))
(list 2 4))
Start with the template from the first exercise and complete FICS Exercise 24. If your template needs updating, compare with cases in the two list template.
Use the built-in function append
and the function cons-all
you
wrote in Lab 5.
Here are some test cases to illustrate the use of the function
comb
(check-expect (comb '(a) 1) '((a)))
(check-expect (comb '(1 2) 1) '((1) (2)))
(check-expect (comb '(1 2 3) 2) '((1 2) (1 3) (2 3)))
Read FICS Section 6
Read about Signatures