Skip to content

Latest commit

 

History

History
20 lines (11 loc) · 1.51 KB

File metadata and controls

20 lines (11 loc) · 1.51 KB

Lab 3.4 - If My Calculations Are Correct...

In this lab, you will write custom reporter blocks to perform a number of useful calculations and computations.

Simple Computations

  1. Write a custom SNAP reporter block called "min" that determines which of two numbers is smaller and reports that value. If the two numbers are equal, report either one.

  2. Write a custom SNAP reporter block called "max" that determines which of two numbers is larger and reports that value. If the two numbers are equal, report either one.

  3. Write a custom SNAP predicate block called "between" that determines if a number is between two other numbers. If the first number is equal to either of the other two numbers or is between them, the block should report "true".

  4. Write a custom SNAP predicate called "at least as long as" that determines whether or not word has at least a specified number of letters.

Stepping Things Up

  1. Write a custom SNAP reporter block called "distance to" that computes and reports the distance from a sprite's position to another point. Use the "x position" and "y position" blocks to determine the sprite's position. Remember that the formula for the distance between points $$(x_1, y_1)$$ and $$(x_2, y_2)$$ is $$\sqrt{((y_2-y_1)^2+(x_2-x_1)^2 )}$$ .

  2. Write a custom SNAP predicate block called "contains letter" that determines whether or not a word contains a particular letter. You can consider upper-case and lower-case letters to be different for the purposes of matching.