COMP2212 Programming Language Concepts Coursework – Submission Two |Haskell|平时作业|

COMP2212 Programming Language Concepts Coursework – Submission Two

Julian Rathke Semester 2 2019/20

Second Five Problems

Here are the second set of problems that I would like you to solve in your new Stream Programming Language. The input and output conventions are exactly as before but I repeat them here for convenience.

Input and output conventions

We will model streams using sequences of integers and, in general, inputs will take the following form:

a11 a21 a31 a41 … an1 a12 a22 a32 a42 … an2 …
a1k a2k a3k a4k … ank …

where every line is terminated with the new line character EOL and the file ends with EOF. The as are arbitrary (positive or negative) 32 bit integers (you can safely use a 64 bit implementation, we will not test for architecture specific overflow behaviour). The number n is the number of input sequences, which are the columns in the input. You can assume that all of the input streams will have the same length, or in other words, that all of the columns will be of the same size. This length will be finite in all tests but may be arbitrarily large. Note that empty inputs are allowed: if you are expecting n sequences and are given an empty input, you should assume that your input is n empty sequences. The values in each row are separated by a single space character. For example, the following is an input that describes 2 sequences of length 3:

21 3 −1 41

For each problem you are expected to produce a single output on stdout. Your output is expected be of the form:

o1
o2
o3 … oN

where the length of the output—that is, the number of lines—will depend on the length of the input. Where the output depends on an input stream that has exhausted its input then no further outputs are required. Every line must be terminated with the Unix new line character EOL (i.e. not Windows CR+LF).

1

Problem 6 – Two-Three Shuffle

Take two sequences a1 a2 a3 a4 a5 … and b1 b2 b3 b4 b5 b6 … as an input and output the sequence a1 a2 b1 b2 b3 a3 a4 b4 b5 b6 . . ., that is, the output sequence alternates between in- put sequences, but reads twice from input one and then three times from input two.

Example input: Expected output: 1

2 155 266 377 483 4 8

Note that input value 8 in the second input stream is consumed as this is the next logical output and is available in the (second) input stream.

Problem 7 – Skip Two then Three

Take a sequence a1 a2 a3 a4 a5 a6 . . . and produce the sequence a3 a7 a10 a14 a17 a21 …

This is the values from the input stream where we skip over two elements, output the next, then skip over three elements, output the next. This is then repeated for the next entries in the input streams.

Example input: 0
0
1

Expected output:

0
0
0 21 02 03 34 05 0

0 4 0 0 5

Problem 8 – Checksum Differences

Take two sequences a1 a2 a3 a4 a5 … and b1 b2 b3 b4 b5 … , and produce the sequence
a1 b1 a2 b2 a3 b3 a4 b4 a5 b5 (a1 −b1 +a2 −b2 +a3 −b3 +a4 −b4 +a5 −b5)…

That is a shuffle of the first input stream and the second input stream but after taking 5 entries from each of the input stream, a checksum value consisting of the the sum of the last five entries of the first input stream less the sum of the last five entries of the second input stream.

2

Example input:

15 24 33 42 51 60

Problem 9 – Counter Padding

Expected output: 1
5
2

4 3 3 4 2 5 1 0 6 0

Take a sequence a1 a2 a3 a4 a5 a6 . . . and produce the sequence
a1 1 a2 2 a3 3 a4 4 …an n…

That is the single input stream is copied to output but in between each entry is a incrementing counter value.

Example input:

23 12 53 90 27 4

Problem 10 – Fibonacci Sequences

Expected output: 23
1
12

2 53 3 90 4 27 5 4 6

Take a sequence a1 a2 a3 a4 a5 . . . and output the sequence
a1 a1 +a2 2a1 +a2 +a3 3a1 +2a2 +a3 +a4 5a1 +3a2 +2a3 +a4 +a5 …

where the coefficients of each input term in the sums follows the Fibonacci series 1 1 2 3 5 8 . . . from when it first appears. Recall that the Fibonacci series starts with two 1s and then the subsequent terms are always the sum of the previous two.

Example input: Expected output: Example input: Expected output: 1111 0123 0237

0 3 4 14 0 5 5 26

3

Second submission – due Thursday May 14th 4pm
What to submit. You will need to submit a single zip file containing:

First, provide the source code for five programs named (pr6.spl, pr7.spl, pr8.spl, pr9.spl, pr10.spl) written in your language that solve the additional problems. We will run our tests on your solutions and award marks for solving the additional problems correctly.

Second, a 3 page report on your language in pdf format named ‘report.pdf’ that explains the main language features, its syntax, including any scoping and lexical rules as well as addi- tional features such as syntax sugar for programmer convenience, type checking, informative error messages, etc. In addition, the report should explain the execution model for the interpreter, e.g. what the states of the runtime are comprised of and how they are transformed during execution. This report, together with the five programs will be evaluated qualitatively and your marks will be awarded for the elegance and flexibility of your solution and the clarity of the report.

Third, a text file called ‘group.txt’ that contains, the usernames of all students in your pair or group, as well as an agreed declaration of how marks are to be distributed amongst the members of your group. For example, 50-50, 60-40 etc. If such an agreed declaration cannot be made then please state this in your declaration instead and arrange for each member of the group to submit separately. Otherwise, please make sure that there is only one submission per group.

How to submit. All submissions must be done through handin.

Marks. This coursework counts for 40% of the total assessment for COMP2212. There are a total of 40 marks available. These are distributed between the two submissions as follows:

Submission one has 10 marks available. There are 2 marks available for functional correctness of each of the first five problems. You will receive the results of Submission 1 prior to the second deadline.

Submission two has 30 marks available. We will award up to 10 marks for the qualitative aspects of your solution, as described in your programming language report. We will award up to 20 marks for your solutions to the second five problems. For each problem there will be 4 marks available for functional correctness only. You have the option of resubmitting the interpreter, for a 50% penalty on this component. If you decide to resubmit your interpreter in the second submission the maximum possible total coursework mark is therefore capped at 30 marks.

Any late submission to either component will be treated as a late submission overall and will be subject to the standard university penalty of 10% per working day late.

4

Leave a Reply

Your email address will not be published. Required fields are marked *