Getting Started

You've built and worked with recursive command blocks. Recursion can also be used in reporters. Thinking and programming with recursive reporters can often help solve otherwise complicated problems.

What exactly is Tony’s map block doing?
Derman: Yours is more complicated.
Sasha: But that pattern was easier to spot (for me).
  1. This block takes two whole numbers as input. Download it and figure out what it does.

    range from ( ) to ( )

  2. Episode 1:
    Derman is staring at this table:
    Input Output
    0 3
    1 5
    2 7
    3 9
    4 11
    5 13

    Tony: In this table, each output is 3 more than twice the input. I have a reporter that will match it.
    2n+3
    Just to be sure, I’ll try it:
    map 2n+3 over [0,5]
    Is Tony right?
  3. Episode 2
    Sasha is looking at Derman’s table from Exercise 2.
    Sasha: I see another way to match the table. If you look down the Output column, each number is two more than the one above it. The only special case is the first row, which doesn't have a row above it, so we have to build in explicitly the fact that if the input is 0 the output should be 3:
    Sasha's version
    Check Sasha's work.
  4. Build Sasha-like (recursive) reporters that agree with each of these blocks on whole numbers.
    2n+7
    2n+5
    n^2+1
    n^2+2
  5. In problem 4, you can check your blocks against the ones in the problem for a long time, but you can’t check them for all numbers. Are there any numbers for which there isn’t a match?
  6. Build Tony-like reporters that agree with each of these blocks on whole numbers.
    q6a
    q6b
    Teacher Feedback: Going from explicit to recursive is hard enough for linear problems; these last two problems that require quadratics are far too hard for high school students who haven't had algebra. These Z and X problems should be in a TIF. --MF
    q6c
    q6d

Experiment with these two blocks, using short input lists, to see what they do:
say each item of list (command)
string items together from (reporter)

Talk with Your Partner
  1. What's the biggest difference between the two blocks?
  2. What are some similarities between them?
  3. What does all but first of do?
  4. Fill in the empty parts of the following definition so that the block reports a sentence containing all the whole numbers from a to b. Note that this question does not involve a list. The inputs are numbers; the reported value is a text string (a sentence). What should the block report in the base case? Where does the recursive call go?
    numbers from A to B numbers from (4) to (12) -->  4 5 6 7 8 9 10 11 12