CSC151 2009F, Class 15: Homogeneous Lists: Making and Manipulating Groups of Drawings Admin: * Yay! We have a prospective! * He should come to Grinnell because of, like, atmosphere and people * And the faculty members who waste class time asking questions like this * Are there any final questions on Exam 1? + "I can't believe you waited this long to clarify the window problem!" + Sam will be relatively sympathetic + What should the cover sheet have? + Your name + The statements + The date + The course * Advance warning: Tomorrow's reading (Anonymous Procedures) duplicates some things you've read before. * Today will be a quick overview then mostly lab day. (Or so I hope!) * Who is missing? Sam should make phone calls. Overview: * Context: What and Why Lists? * Building Lists. * Mapping Lists. * Other List Operations. Goal: Tools to help us build large sequences of similar drawings (because, hey, they look cool, and maybe eventualy KluberMa will call them art) Tool one: The list: A collection of values * Basic ways to make lists * list * append (with two lists) * make-list (boring and repetitive, but as long as you want) * iota (0 1 2 3 4 ... n-1) * Easy to build new lists from old by applying a procedure to each element Long, drawn out and error-filled example. MediaScript [PLT Scheme: MzScheme] v.0.0.1.15 Tue Sep 22 09:55:20 2009 > (list 1 2 3 6 5 4) (1 2 3 6 5 4) > (define d (list 1 2 3 6 5 4)) > d (1 2 3 6 5 4) > (append d d d) (1 2 3 6 5 4 1 2 3 6 5 4 1 2 3 6 5 4) > (make-list 10 4) (4 4 4 4 4 4 4 4 4 4) > (append (make-list 6 4) (make-list 3 10)) (4 4 4 4 4 4 10 10 10) > (define radii (append (make-list 6 4) (make-list 3 10))) > (iota 10) (0 1 2 3 4 5 6 7 8 9) > (map square (iota 10)) (0 1 4 9 16 25 36 49 64 81) > (map increment (iota 10)) (1 2 3 4 5 6 7 8 9 10) > (map square (map increment (iota 10))) (1 4 9 16 25 36 49 64 81 100) > (map increment (map square (iota 10))) (1 2 5 10 17 26 37 50 65 82) > (define sample (drawing-hshift (drawing-vshift (drawing-scale drawing-unit-circle 5) 10) 25)) > (image-show (drawing->image sample 200 200)) 1 > (define hshifts (map times5 (iota 100))) reference to undefined identifier: times5 Interactions:1:21: times5 Interactions:1:16: (map times5 (iota (quote 100))) > (define times5 (lambda (x) (* 5 x))) > (define hshifts (map times5 (iota 100))) > hshifts (0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200 205 210 215 220 225 230 235 240 245 250 255 260 265 270 275 280 285 290 295 300 305 310 315 320 325 330 335 340 345 350 355 360 365 370 375 380 385 390 395 400 405 410 415 420 425 430 435 440 445 450 455 460 465 470 475 480 485 490 495) > (define vshifts (map square (iota 100))) > vshifts (0 1 4 9 16 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361 400 441 484 529 576 625 676 729 784 841 900 961 1024 1089 1156 1225 1296 1369 1444 1521 1600 1681 1764 1849 1936 2025 2116 2209 2304 2401 2500 2601 2704 2809 2916 3025 3136 3249 3364 3481 3600 3721 3844 3969 4096 4225 4356 4489 4624 4761 4900 5041 5184 5329 5476 5625 5776 5929 6084 6241 6400 6561 6724 6889 7056 7225 7396 7569 7744 7921 8100 8281 8464 8649 8836 9025 9216 9409 9604 9801) > (define radii (map increment (iota 100))) > (define sample (map drawing-hshift (map drawing-vshift (map drawing-scale (make-list 100 drawing-unit-circle) 5) 10) 25)) map: expects type as 3rd argument, given: 5; other arguments were: # ((drawing ellipse 0 "" -0.5 -0.5 1 1) (drawing ellipse 0 "" -0.5 -0.5 1 1) (drawing ellipse 0 "" -0.5 -0.5 1 1) (drawing elli... Interactions:4:14: (map drawing-scale (make-list (quote 100) drawing-unit-circle) (quote 5)) Interactions:3:9: (map drawing-vshift (map drawing-scale (make-list (quote 100) drawing-unit-circle) (quote 5)) (quote 10)) Interactions:2:4: (map drawing-hshift (map drawing-vshift (map drawing-scale ((....) ....) (....)) (quote 10)) (quote 25)) > (define sample (map drawing-hshift (map drawing-vshift (map drawing-scale (make-list 100 drawing-unit-circle) radii) vshifts) hshifts)) > sample ((drawing ellipse 0 "" -0.5 -0.5 1 1) (drawing ellipse 0 "" 4.0 0.0 2 2) (drawing ellipse 0 "" 8.5 2.5 3 3) (drawing ellipse 0 "" 13.0 7.0 4 4) (drawing ellipse 0 "" 17.5 13.5 5 5) (drawing ellipse 0 "" 22.0 22.0 6 6) (drawing ellipse 0 "" 26.5 32.5 7 7) (drawing ellipse 0 "" 31.0 45.0 8 8) (drawing ellipse 0 "" 35.5 59.5 9 9) (drawing ellipse 0 "" 40.0 76.0 10 10) (drawing ellipse 0 "" 44.5 94.5 11 11) (drawing ellipse 0 "" 49.0 115.0 12 12) (drawing ellipse 0 "" 53.5 137.5 13 13) (drawing ellipse 0 "" 58.0 162.0 14 14) (drawing ellipse 0 "" 62.5 188.5 15 15) (drawing ellipse 0 "" 67.0 217.0 16 16) (drawing ellipse 0 "" 71.5 247.5 17 17) (drawing ellipse 0 "" 76.0 280.0 18 18) (drawing ellipse 0 "" 80.5 314.5 19 19) (drawing ellipse 0 "" 85.0 351.0 20 20) (drawing ellipse 0 "" 89.5 389.5 21 21) (drawing ellipse 0 "" 94.0 430.0 22 22) (drawing ellipse 0 "" 98.5 472.5 23 23) (drawing ellipse 0 "" 103.0 517.0 24 24) (drawing ellipse 0 "" 107.5 563.5 25 25) (drawing ellipse 0 "" 112.0 612.0 26 26) (drawing ellipse 0 "" 116.5 662.5 27 27) (drawing ellipse 0 "" 121.0 715.0 28 28) (drawing ellipse 0 "" 125.5 769.5 29 29) (drawing ellipse 0 "" 130.0 826.0 30 30) (drawing ellipse 0 "" 134.5 884.5 31 31) (drawing ellipse 0 "" 139.0 945.0 32 32) (drawing ellipse 0 "" 143.5 1007.5 33 33) (drawing ellipse 0 "" 148.0 1072.0 34 34) (drawing ellipse 0 "" 152.5 1138.5 35 35) (drawing ellipse 0 "" 157.0 1207.0 36 36) (drawing ellipse 0 "" 161.5 1277.5 37 37) (drawing ellipse 0 "" 166.0 1350.0 38 38) (drawing ellipse 0 "" 170.5 1424.5 39 39) (drawing ellipse 0 "" 175.0 1501.0 40 40) (drawing ellipse 0 "" 179.5 1579.5 41 41) (drawing ellipse 0 "" 184.0 1660.0 42 42) (drawing ellipse 0 "" 188.5 1742.5 43 43) (drawing ellipse 0 "" 193.0 1827.0 44 44) (drawing ellipse 0 "" 197.5 1913.5 45 45) (drawing ellipse 0 "" 202.0 2002.0 46 46) (drawing ellipse 0 "" 206.5 2092.5 47 47) (drawing ellipse 0 "" 211.0 2185.0 48 48) (drawing ellipse 0 "" 215.5 2279.5 49 49) (drawing ellipse 0 "" 220.0 2376.0 50 50) (drawing ellipse 0 "" 224.5 2474.5 51 51) (drawing ellipse 0 "" 229.0 2575.0 52 52) (drawing ellipse 0 "" 233.5 2677.5 53 53) (drawing ellipse 0 "" 238.0 2782.0 54 54) (drawing ellipse 0 "" 242.5 2888.5 55 55) (drawing ellipse 0 "" 247.0 2997.0 56 56) (drawing ellipse 0 "" 251.5 3107.5 57 57) (drawing ellipse 0 "" 256.0 3220.0 58 58) (drawing ellipse 0 "" 260.5 3334.5 59 59) (drawing ellipse 0 "" 265.0 3451.0 60 60) (drawing ellipse 0 "" 269.5 3569.5 61 61) (drawing ellipse 0 "" 274.0 3690.0 62 62) (drawing ellipse 0 "" 278.5 3812.5 63 63) (drawing ellipse 0 "" 283.0 3937.0 64 64) (drawing ellipse 0 "" 287.5 4063.5 65 65) (drawing ellipse 0 "" 292.0 4192.0 66 66) (drawing ellipse 0 "" 296.5 4322.5 67 67) (drawing ellipse 0 "" 301.0 4455.0 68 68) (drawing ellipse 0 "" 305.5 4589.5 69 69) (drawing ellipse 0 "" 310.0 4726.0 70 70) (drawing ellipse 0 "" 314.5 4864.5 71 71) (drawing ellipse 0 "" 319.0 5005.0 72 72) (drawing ellipse 0 "" 323.5 5147.5 73 73) (drawing ellipse 0 "" 328.0 5292.0 74 74) (drawing ellipse 0 "" 332.5 5438.5 75 75) (drawing ellipse 0 "" 337.0 5587.0 76 76) (drawing ellipse 0 "" 341.5 5737.5 77 77) (drawing ellipse 0 "" 346.0 5890.0 78 78) (drawing ellipse 0 "" 350.5 6044.5 79 79) (drawing ellipse 0 "" 355.0 6201.0 80 80) (drawing ellipse 0 "" 359.5 6359.5 81 81) (drawing ellipse 0 "" 364.0 6520.0 82 82) (drawing ellipse 0 "" 368.5 6682.5 83 83) (drawing ellipse 0 "" 373.0 6847.0 84 84) (drawing ellipse 0 "" 377.5 7013.5 85 85) (drawing ellipse 0 "" 382.0 7182.0 86 86) (drawing ellipse 0 "" 386.5 7352.5 87 87) (drawing ellipse 0 "" 391.0 7525.0 88 88) (drawing ellipse 0 "" 395.5 7699.5 89 89) (drawing ellipse 0 "" 400.0 7876.0 90 90) (drawing ellipse 0 "" 404.5 8054.5 91 91) (drawing ellipse 0 "" 409.0 8235.0 92 92) (drawing ellipse 0 "" 413.5 8417.5 93 93) (drawing ellipse 0 "" 418.0 8602.0 94 94) (drawing ellipse 0 "" 422.5 8788.5 95 95) (drawing ellipse 0 "" 427.0 8977.0 96 96) (drawing ellipse 0 "" 431.5 9167.5 97 97) (drawing ellipse 0 "" 436.0 9360.0 98 98) (drawing ellipse 0 "" 440.5 9554.5 99 99) (drawing ellipse 0 "" 445.0 9751.0 100 100)) > (drawing->image (drawing-compose sample) 300 300) 2 > (image-show 2) 2 > (define tenth (lambda (x) (times 0.1 x))) > (define vshifts (map tenth vshifts)) reference to undefined identifier: times Interactions:1:27: times Interactions:1:26: (times (quote 0.1) x) Interactions:1:16: (map tenth vshifts) > (define tenth (lambda (x) (* 0.1 x))) > (define vshifts (map tenth vshifts)) > vshifts (0 0.1 0.4 0.9 1.6 2.5 3.6 4.9 6.4 8.1 10.0 12.100000000000001 14.4 16.900000000000002 19.6 22.5 25.6 28.900000000000002 32.4 36.1 40.0 44.1 48.400000000000006 52.900000000000006 57.6 62.5 67.60000000000001 72.9 78.4 84.10000000000001 90.0 96.10000000000001 102.4 108.9 115.60000000000001 122.5 129.6 136.9 144.4 152.1 160.0 168.10000000000002 176.4 184.9 193.60000000000002 202.5 211.60000000000002 220.9 230.4 240.10000000000002 250.0 260.1 270.40000000000003 280.90000000000003 291.6 302.5 313.6 324.90000000000003 336.40000000000003 348.1 360.0 372.1 384.40000000000003 396.90000000000003 409.6 422.5 435.6 448.90000000000003 462.40000000000003 476.1 490.0 504.1 518.4 532.9 547.6 562.5 577.6 592.9 608.4 624.1 640.0 656.1 672.4000000000001 688.9000000000001 705.6 722.5 739.6 756.9000000000001 774.4000000000001 792.1 810.0 828.1 846.4000000000001 864.9000000000001 883.6 902.5 921.6 940.9000000000001 960.4000000000001 980.1) > (define sample (map drawing-hshift (map drawing-vshift (map drawing-scale (make-list 100 drawing-unit-circle) radii) vshifts) hshifts)) > (drawing->image (drawing-compose sample) 300 300) 3 > (image-show 3) 3