The video tutorials below are to help you learn how to use aggregates such as lists and structs, and to map functions over lists. Of course you should get DrRacket for your computer platform, to work through the examples.
In case videos aren't your preferred source for learning, I've also included some other resources with each video.
lists of values videoGroup values into lists and then transform the list — extract its first element, produce the reverse list, produce the rest of the list (all but the first element). After you're done with the video you should be able to:
Some non-video resources:
|
structs of values videoGroup values as named parts of structures (or structs). Define a new structure, create a few instances of that structure, and then access the named parts. After you're done with the video, you should be able to:
Some non-video resources:
|
map lists into new lists videoCreate a new list by transforming each list element using the same function. This extremely powerful idea captures a great deal of what programmers need to do. After you're done with the video, you should be able to:
Some non-video resources that may be useful:
|
decompose and reconstruct images videoDeconstruct images into lists of color structs together with information such as width and height. Once you take images apart, you can get at the colors, and completely transform them. Once you're done with the video, you should be able to:
Some non-video resources you may find useful:
|
apply functions to lists videoGenerate powerful effects by taking an arbitrary function and then applying it to a sequence of values in a list. Once you've watched the video, try the exercise below: > (require picturing-programs) > (define L1 (list 1 2 3 4 5)) > (define L2 (list "how" "now" "brown" "cow")) > (define L3 (list (square 5 "solid" "green") (square 6 "solid" "blue") (square 7 "solid" "red))) > (define L4 (list 2 (square 5 "solid" "green"))) > L1 > (apply + L1) > (apply * L1) > L3 > (apply above L3) > L2 > (apply string-append L2) > L4 >(apply scale L4)Think about what you've seen above until you can predict, before you type them into DrRacket, what is produced by the examples below: > (apply + (list 2 3 4 5 6)) > (apply beside (list pic:hacker pic:calendar)) > (apply string-append (list "three" "blind" "mice")) |
filter unwanted elements from lists videoCustomize lists by generating a new list consisting of only the elements you choose. |