Student Name:

 

Formulate the following problems in terms of a map(), a fold(), or a combination of map() and fold(). You do not need to specify the full definition of your map() or fold(); just give a few sentances on what would be performed by each function.

  1. Given a list of vectors [(x1, y1), (x2, y2, z2), ... ], add them to determine the resultant vector. Note that by "vector" we are referring to a physics vector, e.g., a displacement vector.










  2. Given a company's monthly paystubs for all employees for an entire year, calculate how much income tax is owed per-person. Your input will be an unordered list of the form [ (empID1, monthID1, monthlyWage1), (empID1, monthID2, monthlyWage2), (empID5, monthID5, monthlyWage5), ... ], and your output should be of the form [ (empID1, taxOwed1), ... ].










  3. Find the smallest element in an array.










  4. Bonus question: Run-length encoding
    Run-length encoding takes a possibly-repetitive string and rewrites it as a (substring, frequency) pair, eg "aaabccccdd" becomes "a3bc5d2"