Here is the starter code for this lab: Lab 4 Starter Code
You will need to fill in the blocks under "Lab 4: Lists and HOFS" and submit this to Gradescope.

The following blocks are graded:


The autograder contains hidden tests to ensure students do not hardcode their code to pass the tests. To receive full credit, open the starter code and click on the Autograder pallete in the top left area of Snap. Once you have finished coding the above 4 blocks, click on the "run autograder" block. This will run the tests for each block locally. If you pass each test locally and did not hardcode your code to pass the tests, you should also receive full credit for your Gradescope submission.
run autograder output


Look in the Variables palette below the orange variable-related blocks for a bunch of red blocks. These blocks are about lists. A list is a way to combine several values into one grouped value.

The first red block is the list block, used to create a list:
LIST block in the palette

Drag a list block into the scripting area to experiment with.

This block uses a Snap! feature you've seen once before, in the join block: a variadic input. This means that, even though you see one input slot in the block, you can give it any number of inputs. The left and right arrowheads at the end of the block are used to delete or add input slots:
LIST blocks with different numbers of input slots



Like any reporter block, the list block can be dragged into an input slot of another block:
SAY (LIST [the] [Beatles]) The resulting list in a speech bubble

The grey rounded rectangle with red rounded rectangles inside it is the visual representation of a list. Each red rectangle is one list item.

The list picture has several extra widgets: a + button, the down arrow, and so on. When a list value is seen in a variable watcher, you can use these controls to modify the contents of the list directly. But we're not doing that for a while, so for now just focus on the values in the red rectangles.



Try these:
What value do you get if you call the list block with no inputs? (Use the left arrow to delete the original input slot.)

Can you drag other reporters into list input slots to compute the list items?

What happens if you drag a list block into an input slot that expects a number as input, such as the inputs to the arithmetic operators?