In this lab, you will continue practicing processing lists, this time using lists of numbers instead of words.
Write 5 custom reporter blocks that takes a list as an argument. You can assume that all items in the list will be numbers.
- Sum of all the numbers in the list.
- average of all the numbers in the list.
- True if the list contains one negative number and false if all the numbers are non-negative.
- True if each value in the list is greater than or equal to the one before it.
- The largest number in the list.
-
Write a custom reporter block called make all positive that takes a list of numbers as an argument and reports a new list that is the same as the argument, except all negative numbers have been replaced by their absolute value.
-
Write a custom reporter block called only evens that takes a list of numbers as an argument and reports a new list that contains only the even numbers from the list. The result list should have its values in the same order as the original list, but with the odd integers removed. (Remember that mod block can be useful in determining whether or not a number is even.)
-
Save your project as Lab4.4.
Bonus: Write a custom reporter block called add all that takes two list of numbers as arguments and returns a new list that contains the sum of the corresponding values in each argument list. For example, if the arguments to add all are (1, 4, 6) and (2, 2, 3), the result should be (3, 6, 9). You can assume the two lists will be the same size.
Criteria | Points |
---|---|
1.1 sum reporter block | 0.25 |
1.2 average reporter block | 0.25 |
1.3 includes negative predicate block | 0.25 |
1.4 increasing? predicate block | 0.25 |
1.5 maximum reporter block | 0.25 |
2.1 make all positive reporter block | 0.5 |
2.2 only evens reporter block | 0.25 |
Bonus: add all reporter block | 0.25 |
Total | 2.0 |