UNB/ CS/ David Bremner/ teaching/ cs2613/ tests/ T1/ CS2613 Sample quiz 1

This is Quiz 1 from Fall 2023. Quiz 1 for Fall 2024 will be similar but ask you to write a different function, and have slightly different rules.

Instructions

  1. This quiz is printed double-sided. Read both sides starting to work.

  2. This quiz is individual, all answers must be your own work.

  3. Your answers should be written to a directory tests/quiz1 in your cs2613 git repository, i.e. in ~/cs2613/tests/quiz1

  4. You have 50 minutes to complete the quiz. It must be committed and pushed to https://vcs.cs.unb.ca by 10:20AM. If you have trouble committing and pushing your work, ask for help before the deadline.

  5. This quiz is open book. You can use

    • The course web site

    • The local mirror of A Functional Introduction to Computer Science (FICS).

    • Your own work from labs and assignments (as long as it is on lab machines or https://vcs.cs.unb.ca).

    • The local Racket documentation (run "raco docs", or the drracket help menu).

    Any other site (for example stack overflow) is cheating. Use of personal devices (phones, laptops, etc...) is not permitted.

  6. If in doubt, comment your answers. Incorrect answers with no explanation will receive little or no credit.

  7. After you have committed and pushed your completed quiz, fill out the following and hand in this sheet.

Quiz 1 is committed and pushed (sign)
Name as recorded in D2L
Student ID Number
Username
output from
git rev-parse --short=7 HEAD
output from
git rev-parse --short=7 origin/master

The last two 7 digit hashes must be identical. If they are not, ask for help.

Question

For this quiz you will write a Racket function unique-left (discussed in Chapter 5 of FICS and Assignment 2). This function keeps the first occurence of each element in a list. You may write helper functions according to the rules below. You don't need to use all of the constructs specified below, but you will be penalized for using non-specified constructs. There are a total of 10 marks possible on this quiz.

Passing

To get 6 marks (roughly a "C+") your solution must

    (check-expect
     (unique-left (list 1 4 2 1 5 4))
     (list 1 4 2 5))
    (check-expect
     (unique-left (list 1 2 "hello" 3 "hello" 2 1))
     (list 1 2 "hello" 3))

Full Marks

To get the maximum 10 marks, your solution must