Writing Twitter Apps
Twitter is a very successful viral social network that enables the microblogging phenomenon (i.e., blog entries that are only 160 characters in length that are amenable to transmission on mobile phones). It has been adopted by a diverse audience from US Senators to kids.
In this final lab, you we study the API documentation and figure out how to parse (i.e., convert the raw XML input from Twitter to useful Scheme structs). You do not have to figure out the authentication system nor do you need to sign up for Twitter. Many tweets (i.e., Twitter microblogs) are available to public without need for authentication. For example, this example gives a timeline of tweets which are CNN headlines.
Your assignment is to use the full “module” language in DrScheme to parse http://twitter.com/statuses/user_timeline/cnnbrk.xml into a list of tweet structs where a tweet struct has fields for the “text” and “created_at” parts of of the “status”. You may ignore all the other parts of the xml file.
Do consult Scheme’s Help Desk to learn how to use the XML, pattern matching, and net/url facilities.
Midterm Solutions
; flatten : list of tree -> list of tree ; to produce a list of tree which is all of the children of root nodes of the trees appended together ; Ex: see exam (define (flatten ls) (foldr append empty (map tree-children ls))) ; levels : tree -> list of list of number ; to produce a list of list of numbers which each enclosed list is all the numbers in the input list at a given depth ; Ex: see exam (define (levels t) (local [(define (helper ls) (cond [(empty? ls) empty] [else (cons (map tree-key ls) (helper (flatten ls)))]))] (helper (list t))))
Project 4A: Vector! (Due Monday, July 20)
- A dot product of two vectors (of the same length) a and b is the sum of the pairwise sum (i.e., a0*b0 + a1*b1 + … + an*bn). Please write a function dotproduct that takes two vectors of numbers and produces the dot product of the two.
- Please revisit the birthday problem from the earlier assignment. We implemented the birthday bucket list using a list. As it turns out, if you have enough friends, this can be rather slow. Re-implement the birthday example (i.e., a function that takes a list of profiles and produces the names organized by birthday) using a vector of buckets rather than a list of buckets as before. Because we do not know a priori nor can we guess how many people share the same birthday, the contents of each bucket is still a birthday and a list of names. Run some sample inputs (length 100, 1000, 10000) using both the list- and vector-based bucket. Which is faster? Please include a table of your performance numbers in your submission.
Hints: How long is your vector going to be? 365, one for each day of the year. You can use build-list to produce on sample inputs.