En este laboratorio, tú vas a desarrollar herramientas que ayudarán a resolver una sopa de letras mediante la búsqeuda de palabras que cumplan con ciertas características.
En esta página, tú vas a revisar predicados y construir algunos que podrás utilizar en otros proyectos.
As you know, predicates are reporter blocks (functions) that always report a Boolean value (they report only the values or
). In Snap!, predicates are represented by hexagonal blocks. They compute the condition used by conditionals (such as
if
, if else
, or repeat until
) to decide when to do something. Predicates ask a question such as "Is the random number 3?" or "Is this sprite touching the sprite called 'Leader'?"
Every if else
block has two scripts inside of it, exactly one of which will be run depending on the value that the predicate reports. Then the computer continues with whatever comes after the if else
block.
=, >, <, ≥, ≤as well as a sixth:
≠, which means "not-equal" and reports
false
if the two inputs are equal and otherwise reports true
(if they are not equal). When you write the These six relational operators all report a Boolean value (true
or false
).
Selection means deciding (selecting) which part of an algorithm to run based on whether a condition is true or false.
Every algorithm can be constructed using sequencing (following steps in order), selection (deciding), and iteration (repeating).