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
This quiz is printed double-sided. Read both sides starting to work.
This quiz is individual, all answers must be your own work.
Your answers should be written to a directory
tests/quiz1
in yourcs2613
git repository, i.e. in~/cs2613/tests/quiz1
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.
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.
If in doubt, comment your answers. Incorrect answers with no explanation will receive little or no credit.
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
Use the
Beginning Student
language (or#lang htdp/bsl
).Use only function definition, function application,
cond
,empty?
,cons
,cons?
,first
,rest
, andequal?
andremove-all
.pass the following tests.
(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))
Have full test coverage
Be nicely indented and use reasonable identifiers (functions and variable names).
Full Marks
To get the maximum 10 marks, your solution must
Not use
remove-all
, i.e. use only function definition, function application,cond
,empty?
,cons
,cons?
,first
,rest
, andequal?
.Include at least one logically distinct new test, with a comment explaining what it tests.