CPSC 110 Lecture Notes - Lecture 16: Empty String, Doberman Pinscher, Border Collie

224 views6 pages
Verified Note
26 Oct 2018
School
Course
Professor

Document Summary

;; problem 1: refactor this function to use built in abstract functions. (@htdf keep-positive) (@signature (listof integer) -> (listof integer)) ;; produce list that only includes positive number from loi (check-expect (keep-positive empty) empty) (check-expect (keep-positive (list 2 3 -8 9 -11 -14)) (list 2 3 9)) (@template (listof integer)) (define (keep-positive loi) (cond [(empty? loi) empty] [else (if (positive? (first loi)) (cons (first loi) (keep-positive (rest loi))) (keep-positive (rest loi)))])) (@template use-abstract-fn) (define (keep-positive loi) (filter positive? loi)) ;; problem 2: complete the design of this function that produce list that only. ;; includes the values that are less than 10 using built-in abstract functions. (@htdf less-than-10-only) (@signature (listof integer) -> (listof integer)) ;; produce list that only includes the values that are less than 10 (check-expect (less-than-10-only empty) empty) (check-expect (less-than-10-only (list -2 3 8 9 11 14)) (list -2 3 8 9))

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents