Midterm 1 - Math 2041 - September 25, 2018 - 11:30am-12:45pm



You have 1 hour 15 minutes to complete the following questions.
Make sure that it is finished and uploaded before this time.

Question #1:
The input of the following function is a list of integers L:

> dig:=proc(L)
description "please tell me what this function does";
return [seq(seq([L[j],L[i]],i=j+1..nops(L)),j=1..nops(L))];
end proc;

Copy the function from this page into Maple. Call the function several times with different examples of input. Describe in words how the input relates to the output. Answer the question:

What should be the description of the function so that it appropriately describes the relationship of the output with the input?






Question #2:
Write a function called sum_thresh with input equal to L (a list of integers) and t (an integer). The output of the function should be the sum of the values which are greater than or equal to t.

For example we should see:
> sum_thresh([-3,-1,11,5,-6,4,1,-4,5],4);
25
> sum_thresh([-3,-1,11,5,-6,4,1,-4,5],15);
0
> sum_thresh([-3,-1,11,5,-6,4,1,-4,5],10);
11
> sum_thresh([-3,-1,11,5,-6,4,1,-4,5],11);
11


















Question #3:
Write a function cycle which has as input a non-empty list L and it returns a new list where the last entry of the output is the first entry of L and the other entries of the output are the second through nops(L) entries in the same order.

For example we should see:
> cycle([1,2,3,4,5]);
[2, 3, 4, 5, 1]
> cycle([1,3,5,7,9,12,-1]);
[3, 5, 7, 9, 12, -1, 1]
> cycle([5]);
[5]







































Place your name on the top of this sheet. Write your answers to the questions on this paper. Make sure that you carefully copy punctuation correctly as part of your answer.
The text for this midterm can be found at http://garsia.math.yorku.ca/~zabrocki/math2041f18/midterm1.html in case you want to copy/paste the lines into a worksheet. You should be able to complete this quiz within the class time and you should hand your work into the TA.

You are expected to work alone on this assignment. Any indication of academic dishonesty will result in a 0 for the assignment and possible higher penalties.