Assignment 2: MyFace

posted by: Ms. Martin 6 October 2010 4 Comments

Thanks to Mike Gennert for the assignment this is based on.

You will be submitting this assignment for electronic grading by Thursday October 14th.  You must submit a file named my-face.rkt.

The Goals

  • Make sure you can write programs over lists of structures
  • Practice using map and filter as appropriate
  • Practice using helper functions

The Assignment

You should be using map and filter when it is possible to do so keeping in mind that not all functions can use them.  Use helpers to increase readability.  Don’t forget your signatures!  I will be looking for consistent indentation, boolean zen, good helpers, etc.

  1. profile consists of a member’s name, age, the school s/he attends, and a list of activities s/he participates in. A network is a list of profiles.Write data definitions and provide examples of data for activities list, profile, and network.
  2. Write a function members that consumes a network and produces a list of all the members’ names.
  3. Write a function active-members that consumes a network and produces a list of names of members who engage in 3 or more activities.
  4. Write a function schools that consumes a network and produces a list of all the schools attended. No school may appear more than once.
  5. Write a function count-members-at-school that consumes a school name and a network and produces the number of members at that school.
  6. Write a function average-age that consumes a network and produces the average age of its members. Assume that the network is non-empty.
  7. Write a function same-activities that consumes 2 people’s names and a network and produces a list of those activities that both participate in.
  8. It is important that MyFace protect the information of young members. Write a function create-profile that consumes the same data as make-profile and produces a profile. If the member’s age is less than 14, the name in the returned profile is left blank, otherwise the name that is supplied is used. This is a common technique for adding data checking features to constructors.
  9. Write a function add-activity-to-member that consumes an activity and a profile and returns a profile that includes the activity. If the activity is already present, it is not repeated.
  10. MyFace realizes that some members have forgotten to include “MyFace” as an activity. Write a function add-activity-to-everyone that consumes an activity and a network and produces a network where every member participates in that activity exactly once.
  11. A nearby school has decided to change its name. Rather than update all student profiles individually, write a function rename-school that consumes two school names and a network, producing a network in which everyone who formerly attended the first school now attends the second and everyone else is as before.
1 Star2 Stars3 Stars4 Stars5 Stars (17 votes, average: 2.82 out of 5)
Loading ... Loading ...

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>