Collection Methods 10 3 2011 Opening Discussion Do you have any questions about the quiz Minute essay comments How long do you have to correct assignments There will be a study guide The test covers everything we have done I did write the spreadsheet and the quiz average is dropping the lowest Looking back and moving forward 2 D arrays Array Array Use zip to work on two things at once More Everything we are doing works on both Lists and Arrays Examples at the end of class today Standard Methods There are lots of methods on collections The API can help us see all of them Part of collections Boolean tests contains endsWith isEmpty nonEmpty startsWith Searching drop init last slice splitAt take takeRight indexOf lastIndexOf Other mkString reverse zip zipWithIndex Other Methods If the elements in a list support addition or multiplication you can use the sum and product methods If they are ordered you can do min and max Having sum and length makes averages really easy With min you can even drop a grade easily Higher Order Methods The most powerful methods are ones you can pass functions into exists forall Boolean checks like for math filter partition separate collection based on Boolean map apply function to all the elements reduceLeft apply function moving through collection foldLeft apply function moving through but allows initial value so it can return a different type This is curried Let s Put These Into Action I want to spend the rest of the class time playing with these methods and seeing what we can do with them A String is a collection so you can do these things with a String as well String also has a method called split BLS data ftp ftp bls gov pub time series la Minute Essay What questions do you have Getting your head around the higher order methods can take time Practice is your best friend
View Full Document