CSCI0050 List Functions Assignment
CSCI0050 Homework: Processing Lists

Due: Friday, July 14 at 6pm (submit through Canvas)

Assignment Goals:
  • To practice developing and testing functions that process lists

Collaboration Policy: You may work on this assignment with others. Include a collaboration statement describing how you did the work.

Exercises: Processing Lists

Put your answers to these questions in a file named votes.arr.

For this assignment, you will write some functions that lie at the heart of running elections. There are different methods for counting ballots in elections. This assignment explores two. In our elections, everyone indicates their first and second choice candidates. Some elections will count only the first-choice votes, while others do a weighted combination of the first-choice and second-choice votes.

Two tables will provide the data for an election:

Starting from this setup, do the following exercises:

Tips and Hints

You do NOT need to use the material from Wednesday about accumulators or passing functions as arguments as part of this homework (though you may if you wish). This isn’t meant to be complicated. I just want to make sure that everyone has had some experience writing list functions going into lectures next week.

Grading and Expectations

In grading, we will look at your examples/tests, code structure, and code presentation. We expect you to follow the list template when appropriate (unless you are using a built-in list iterator like map or filter, which you are welcome to use if you wish).

Remember to include the collaboration statement.

If you want to check whether your file has the same names as our grading scripts will look for, insert the following code at the bottom of your file. This simply looks for the names and types that we stipulated in the assignment. If one of these checks fails, fix your code, not these checks.

  fun col-name-test(table):

    select choice1, choice2 from table end










What/how to turn in

Create a directory named votes-hwk. Inside the directory, put a single Pyret file named votes.arr. Submit a zip of the votes-hwk directory. Even though you are submitting only one file, we need the directory to set up the scripts that will run some correctness checks against your homework.

Make sure you follow these directory and file names exactly, or we won’t be able to grade your work.