CS计算机代考程序代写 Haskell 0/16 Questions Answered

0/16 Questions Answered
Mid-Semester Exam (COMP1100)
STUDENT NAME
Search students by name or email… ! Q1 Acknowledgment
0 Points
COMP1100 Mid-Semester Exam, Semester 1 2021
You must acknowledge the following integrity pledge before proceeding. Please read carefully and check all the boxes.
I am committed to being a person of integrity.
I pledge, as a member of the ANU community, to abide by and uphold the standards of academic integrity outlined in the ANU statement on honesty and plagiarism, I am aware of the relevant legislation, and understand the consequences of breaching those rules.
I will not communicate in any way with anyone else during this exam. This includes asking questions in any online forum.

I acknowledge that this exam is protected by copyright

I acknowledge that this exam is protected by copyright
and that copying or sharing any of its content will violate that copyright.
Read and check off the following instructions:
1. This examination is timed.
Note the remaining time at the top right of this screen. Set an alarm for yourself if you need one.
2. Permitted materials. This is an open book exam. You might in particular find the
course Website, the Prelude documentation, and the Data.List documentation useful.
You may use any documentation you wish but all work must be your own.
Save Answer
Q2 Types 2.5 Points
Consider the following Haskell function signature:
foo :: String -> Int -> String
Select which of the following is false:
# foo “a” 1 can be given a type.
# foo “a” can be given a type.
# foo “a” 1 “a” can be given a type.
# foo [‘a’,’b’] has type Int -> String . # foo “abc” 2 has type String .

Q3 Haskell Functions 2.5 Points
Consider the following Haskell type signature:
myFun :: Bool -> Bool -> Bool
Four of the following implementations of this function behave
the same.
A.
myFun a b = case (a,b) of
(False, False) -> True
(True, True) -> True
(True, False) -> False
(False, True) -> False
B.
C.
D.
myFun a b = a == b
myFun a b
| a == True && b == True = True
| otherwise = False
myFun a b = (a && b) || not (a || b)
E.
Save Answer

myFun False False = True
myFun a b = a && b
Select which one behaves differently than the others? #A
#B
#C
#D #E
Save Answer
Q4 Type Signatures 2.5 Points
Consider the following Haskell function definition:
bar a b = abs a + a / b
Which of the following is a valid Haskell type signature for this
function?
# bar :: Integer -> Integer -> Double # bar :: Int -> Double -> Double
# bar::Int->Int->Int
# bar :: Int -> Int -> Double
# bar :: Double -> Double -> Double Save Answer
Q5 Lists
2.5 Points

2.5 Points
Which of the following statements is false in Haskell: # A list of functions can be defined.
# [[], [], [[]], [1]] is a valid list.
# Lists can be used in recursive functions.
# Infinite lists can be constructed.
# An empty list is often used as a base case in recursion.
Save Answer
Q6 Sets and Functions 5 Points
Select which of the following are True or False:
Q6.1 Sets 1 Point
(False, 1) is an element of the set B + Z. # True
# False
Save Answer
Q6.2 Functions 1 Point
Given f :: A ¡ú (B ¡ú C), a an element of A, and b an element of B, then (f(a))(b) is an element of C.
# True # False
Save Answer

Q6.3 Functions 1 Point
Mathematical functions are pure. # True
# False
Save Answer
Q6.4 Sets and Functions 1 Point
Given sets A and B, then A ¡ú B represents the set of all possible functions from A to B.
# True # False
Save Answer
Q6.5 Sets 1 Point
The set B ¡Á B has 8 elements. # True
# False
Save Answer
Q7 Haskell 2 Points
Select which of the following are True or False:

Q7.1 Type Safety 1 Point
Haskell is dynamically typed. # True
# False
Save Answer
Q7.2 Lists 1 Point
A list in Haskell can only have elements of the same type. # True
# False
Save Answer
Q8 Lists and Strings 3 Points
Consider the following Haskell function definition:
tail’ xs = case xs of
[] -> []
_:ys -> ys
Select which of the following are True or False:
Q8.1 Strings 1 Point
A valid type signature for the expression tail’ “comp1100” is [Char] .

[Char] .
# True # False
Save Answer
Q8.2 Lists 1 Point
tail’ [] gives the same result as tail’ [[]] . # True
# False
Save Answer
Q8.3 Lists 1 Point
tail’ [True, False] returns False . # True
# False
Save Answer
Q9 Programming 30 Points
The programming questions are distributed to you via gitlab.
You can find the exam gitlab repository at https://exam- gitlab.cecs.anu.edu.au.
Do not change the name of this repository, or we will not be able to mark your exam.
You should clone your repository to your local machine to do your work.

your work.
During the exam, tutors will be available on Piazza and Teams so that students can get help in case of technical problems. Once you have cloned the exam you should answer the programming questions in the given Haskell files.
After you complete each question you should commit and push your work to gitlab. We recommend that you check if your push was successful at your repository on gitlab.
Save Answer
Save All Answers Submit & View Submission $