CSC151.01 2006S, Class 29: Vectors Admin: * Due: Project 1 Writeup. * No homework during break. No reading for Monday. No coding for Tuesday. Nothing. But you may get a survey when you return * The things they didn't tell me: The original designers of the labs didn't expect most students to get all the way through, or even most of the way through * Be careful: Friday the 13th falls on a Friday. Overview: * Problems with lists. * A solution: Vectors. * Lab. Issue: We need to group data Solution: Lists * Easy to extend with cons * Easy to take apart with car and cdr * Lots of procedures Basic: cons, car, cdr, null, null? Advanced: reverse, list-ref, member, append Our own: member? , tally, ... * Problem with lists * The cost of accessing an element depends on the position in the list * Without care, might write inefficient code Solution to problems with lists: Vectors * An indexed collection of values * Main operation: vector-ref * A lot like list-ref, but always "one step" * Problem: Fixed size - Hard to "make larger" * Other benefit: Mutable (vector-set! vec pos newval)