6.3. Keep & Combine

The other two blocks we will use that take other blocks as input are Keep* and **Combine. This video introduces them:

Checkpoint Exercises

../../_images/BYOB63a.png

All of the checkpoint exercises will work on the lists shown to the right. Start by making lists that look like them.

Hint:

The combine with block should have two blanks in the reporter you use for “smashing things together”. Like this:

../../_images/BYOB63b.png

If you put something in one of the blanks it won’t work right!

Keep Exercises

Keep less than 80

Use Keep to filter the list of numbers down to those less than 80.

../../_images/CP63a.png

Keep long words

Use Keep to filter the list of words down to only words with a length of more than 4.

You need to use the length block.
../../_images/CP63b.png

Combine Exercises

Multiply

Use Combine to multiply all the numbers in the numbers list together.

../../_images/CP63e.png

Select Minimum

Make a reporter block that returns the smaller of two values. Use Combine and that block to combine the list of numbers - you should get 68. Use them to combine the words, you should get “i” (the lowest alphabetically).

../../_images/CP63f.png

Select Longest

Make a reporter block that returns the longer of two words. Use Combine and that block to combine the list of words - you should get “programming”, the longest word

../../_images/CP63g.png