In the lists labs and your previous assignments, you've been exposed to HOF blocks like map
, keep
, and
combine
.
You likely used them to carry out relatively simple tasks, like summing a list with combine
, or filtering based on word length
with keep
.
In this lab, you're going to attack some more complicated problems with the help of HOFs. In addition, you're going to see how functions
can be treated as data, and how you can define your own blocks that take in functions as input, just like map
,
keep
, and combine
do.
Here is the starter code for this lab: Lab 9 starter code
The following blocks are graded:
For all the required blocks below, you may use only HOF blocks. Recursion and iteration are not allowed.
Before we dive into the more intense HOFs problems, let's warm up with a few non-HOFs problems (meaning that you are allowed to use iteration or recursion for these blocks). These simpler blocks will come in handy later when we attempt the more complex problems. We realize you may have built these blocks before, but you should build them again anyway! If you already know how to do them cditeratively, try them recursively, or vice versa!
First, create the block
that takes in a minimum and a maximum, and reports a list of numbers from the minimum to the maximum (both inclusive). So, for example,
would report the list
Please do NOT use the "numbers from () to ()" block in your implementation!
Next, create the block
that that takes in a word and reports a list of all of the characters in that word. So, for example,
would report the list
Similarly, please do not use the "word->list" block that is already provided in Snap!