CSCI0050 2018 List Functions Assignment
CSCI0050 Homework #5: Processing Lists and Creating Data

Due: Friday, July 20 at 6pm (submit through this Google form)

Late Policy: Files are due by 6pm. No late work will be accepted.

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

  • To pratice working with data blocks

Collaboration Policy: You may work on this assignment with others. Include a collaboration statement describing who you worked with.

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:

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

  end

  

  check:

    is-function(num-votes-for) is true

    is-function(write-ins) is true

    is-function(tally-most-votes) is true

    is-function(tally-pref-votes) is true

    col-name-test(votes-diff-result) is true

  end

What/how to turn in

Submit your votes.arr file. Make sure it has this exact file name so we can run our grading program on your work.