emojify
block works, add additional emojis to it, and learn how to search a list using emojify
block you've used already takes a sentence as input and uses emojify word
to process each word.emojify word
block takes a single word as input. If that word has a matching emoji inside the block's code, it reports that emoji. Otherwise, it just reports the input word. Try the following inputs in the emojify word
block:
Find First
to Make Emojify Word
Like map
, the find first
block is a higher-order function because it takes a function (the predicate) as input.
The emojify word
block uses to search for a matching emoji. The first input to
find first
is a predicate, a hexagon-shaped reporter that reports a true/false value. The second input is a list. The find first
block reports the first item in the list that makes the predicate true. For example,
Find first
uses the predicate to check each item from the input list. The blank in the predicate is where each item from the list goes as it is checked.
The emojify word
block uses find first
to search a list of lists (a list with lists inside it).
The list being searched is a list of lists. These two find first
expressions are searching for the first list in the list of lists that has certain word as its first item. When searching for a list with the first item "car", find first
found a matching list: When searching for a list with the first item "dinosaur",
find first
found no matching list.
emojify word (cat)
report?emojify word (cow)
report?emojify word (cow)
report an emoji of a cow? (You'll have a chance to add word/emoji pairs soon!)If Then Else
to Make Emoji from Pair
The emojify word
block also uses to check if there is a match by using
if then else
. For example, if there is a matching list, it reports the emoji from the list:
And if there is no match, it reports the input word that should be reported otherwise:
emoji from pair
block uses if then else
to do this job.The is () a ()?
predicate takes two inputs, the first can be anything, and the second is the name of a type of value (number, text, list, etc.). If the first input is of the type selected in the second input, the block will report true; otherwise, it will report false. In this case, if the pair is a list, it will report true, and if not, it will report false.
if then else
expression inside emoji from pair
.)Emojify Word
to Make Emojify
emojify word
block. You can type a whole sentence into the emojify
block, and it will replace any words from the word/emoji pair list with their matching emojis. Try it for a few sentences using some of the words with matching emojis in the list.emojify
block and select "Edit". Discuss how this block works.emojify
block works. Include the following:
emojify word
doesjoin
, map
, and split
blocks are usedClick for an example of what happens.
If the input text is "I love rain", that first gets split
into the list "I", "love", "rain"; then emojify word
gets map
ped over each word (join
ed with a space at the end of each word), resulting in the list "I ", "❤️ ", "☔️ "; and finally, that list is join
ed into "I ❤️ ☔️ ".
Here's the same process in a diagram:
emojify
that describes the input and output.
emojify word
to make emojify
translate a word of your choosing into an emoji of your choosing. Test your work in emojify word
first, and then by trying a sentence with that word as input to emojify
.
Click for hints about adding more word/emoji pairs to the emojify word
block.
list
block (the list of lists). You should see a new input slot appear at the end of the list.
list
block into the new input slot.map
, join
, split
, and if
blocks, you learned about a new block