CSCI0050 2019 List Functions Assignment
CSCI0050 Homework #6: Processing Lists and Creating Data

Due: Friday, July 19 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, except for the Data Druid exercises which you should do solo. Include a collaboration statement describing who you worked with.

Please do the Druid problems in order, finishing one before you look at the setup for the next.

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

  end

What/how to turn in

Submit four files to the google form at the top of the page: votes.arr, tally-most-votes-examples.arr, tally-pref-votes-examples.arr, and voting-same-winner-examples.arr.