In this lab, you will implement several custom blocks performing variants of sequential search.
- Write your own version of the SNAP "contains" block, which takes a list and a value as arguments and reports true if the value is anywhere in the list and reports false otherwise. You should NOT use the existing "contains" block in your implementation.
- Write a custom block called "index of" that takes a list and a value as arguments and reports the index at which the value is found in the list, if it is there. If the value is not present anywhere in the list, report -1. So, for example, if the list is (2, 3, 5, 7, 11) and the value is 5, "index of" should report 3. If the list is (2, 3, 5, 7, 11) and the value is 4, "index of" should report -1.
-
Write a custom block called "first e-word" that takes a list as an argument and reports the first word in the list that starts with the letter 'e'. If no such word exists, report a blank (nothing).
-
BONUS: Write a custom block called "first word that starts with" that takes a list and a letter as arguments, and reports the first word in the list that starts with the given letter. If no such word exists, report a blank (nothing).
Lab 4.5 Criteria | |
---|---|
1.1 contains block | 0.5 points |
2.1 index of block | 0.5 points |
3.1 first e-word block | 1.0 points |
3.2 BONUS: first word that starts with block | 0.5 points |
PROJECT TOTAL | 2.5 points |