这是一篇来自加拿大的代码作业代写,以下是作业具体要求
Reminder: All work submitted must be your own.
If you have a question about something that is not specific to your own code, the best way to get help is to post a public question on Piazza.
If you have a question about something that is specific to your own code, you can:
- post a private question on Piazza (only the instructor and TAs will see it), or
- attend office hours, or
- email the instructor.
If you are asking for help about your own code, please paste it rather than sending a screenshot.
Most of the questions on this assignment are about writing code, but the last part is about stepping. Please write your answers to that part within the comment at the end of a1.hs.
Start early: Even if some questions look easy to you, Haskell is probably very different from the languages you have seen, and you may need more time than you think.
Late policy: Assignments submitted up to 24 hours late (that is, by 11:59 pm the following day) will be accepted without penalty. Assignments submitted more than 24 hours late will not be accepted except with an accommodation or consideration.
0 IMPORTANT: Your file must compile
Your file must load (:load in GHCi) successfully, or we will deduct 30% from your mark.
If you are halfway through a problem and run out of time, comment out the code that is causing :load to fail by surrounding it with {– . . . –}, and write a comment describing what you were trying to do. We can sometimes give some marks for evidence of progress towards a solution,but we need the file to load and compile.
Do not import unnecessary modules. This goes especially for modules that are only available on a particular platform, such as Windows graphics libraries. Such modules are definitely unnecessary for this assignment, and including them may cause your code to compile on your computer but not on our computers.
0 Document your code
Much of this assignment is “fill-in-the-blanks”. If we have asked you to write a specific function,you do not need to explain what your code does.
If you need to declare any new functions (“helper functions”), write a comment that explains what your function does.
Strive for simplicity
You should try to find a simple solution. You do not have to find the simplest possible solution to get full marks, but you should not have an excessively complicated solution. Marks will be deducted if your solution is too complicated. If you are worried about whether your solution is too complicated, contact the instructor.
0 Be careful with library functions
Haskell has a rather large built-in library. This assignment is not about how to find library functions,but about how to use some of the core features of Haskell. You will not receive many marks if you just call a library function that solves the whole problem. The point is to solve the problem yourself.
If you are not sure whether you are calling a library function that solves the whole problem,contact the instructor. Note that if we suggest a library function, you may use it.
(The only way I know to avoid this issue is to craft questions that are complicated and arbitrary,such that no library function can possibly solve them. I don’t enjoy asking complicated and arbitrary questions.)
0 Test cases
Not all questions on CISC 360 assignments will include test cases. When test cases are given,passing all the test cases does not guarantee full marks. This is for several reasons:
- We may test your code using test cases that we have not given you.
- In general, testing can only show the presence of bugs (when a test case fails), not the absence of bugs.
When test cases are given, they will usually be in the form of declarations starting with “test ”,of type Bool. These should return True. For example, after completing Q2, typing “test square1” into ghci should print True.
Again: Passing all the test cases we give you does not guarantee full marks.
1 Add your student ID
The file a1.hs will not compile until you add your student ID number by writing it after the =:
— Your student ID:
student_id :: Integer
student_id =
You don’t need to write your name. (When we download your submission, onQ includes your name in the filename.)
2 Writing and testing small Haskell functions
2.1 sqroot
This function takes two integers m and n, and should return True iff one integer is the principal square root of the other. That is, it should return True if and only if
- m > 0 and m2 = n, or
- n > 0 and n 2 = m.
Fill in the definition of sqroot by replacing the word undefined with appropriate Haskell code,and, if necessary, modifying the = (for example, if you decide to define sqroot using guards).
3 gallop
In this question, you need to write a function gallop. Your function must be recursive—its definition will call itself. Follow the specification given:
Q3:
‘gallop’: given two integer arguments ‘dir’ and ‘span’, returns 1 if ‘dir’ is less than or equal to 0,and otherwise returns (span * dir) * gallop (dir – 10) (span * dir)
Hint: We intentionally wrote the specification using Haskell syntax, so most of the code you need is already in the above specification.
4 gallop seq
In this question, you’ll need to return Haskell strings, which are lists of characters. We have not discussed lists in any detail; however, for this problem, you should need only the following:
- To return a string containing a single character, say 0, write
[’0’]
You could also write “0”.
- To concatenate (append) two strings, use the built-in function ++. For example:
[’1’, ’2’, 3’] ++ [’4’]
returns “1234”, which is the same thing as [’1’, ’2’, ’3’, ’4’].
- To convert an integer to its string (in decimal), call the built-in function show:
(show 360) returns the string “360”.
The full specification of gallop seq is given in a1.hs.
5 Stepping questions
5.1 First expression
These questions ask you to step two small expressions. For example, the first stepping question asks you to do the three steps needed to get the result. Replace the parts. When writing a function application step, state the substitution.
5.2 Second expression
The second expression is somewhat larger than the first, and uses a function square, defined in a1.hs.
Hint: The first step does not apply (call) the function square.
5.3 Third expression
The third expression only needs to be stepped once, but you can’t directly check that your answer matches what Haskell does, because the result contains a function and Haskell won’t print functions.
程序辅导定制C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB

本网站支持 Alipay WeChatPay PayPal等支付方式
E-mail: vipdue@outlook.com 微信号:vipnxx
如果您使用手机请先保存二维码,微信识别。如果用电脑,直接掏出手机果断扫描。
