CSC104H1 Lecture Notes - Lecture 17: Substring

36 views3 pages
School
Course
Professor

Document Summary

Csc104 computational thinking lecture notes 17: list of strings, fibonacci sequence: we want to flatten a many-level list, lists contains many level may like: (list (list bat rat) mouse (list (list cat dog snail) (list dolphin)))) A natural thought is: take a look at each element of the original list, and flatten the ones that need to be flattened. But we can save ourselves effort by not worrying about which ones must be flattened, and make the computer work more instead: make it flatten each element: (define (flatten anything) (cond [(list? anything) (apply append (map flatten anything))] [else (list anything)])) (step parallel (flatten (list 1 (list 2 3) [else (list (list 1 (list 2 3) (list (list 4 5) (list 6))))]): evaluate the question (cond #true (apply append (map statement of the first condition flatten (list 1 (list 2 3) (list (list 4 5) (list 6)))))]

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