34 — Chart: seeing numbers as bars
A column of numbers takes a while to read. The same numbers as bar lengths are understood immediately. It is the bar from guide 21 again, except each one is drawn to its own number rather than to the step count.
Steps
Keep two lists side by side. One holds the names, the other the numbers, and the same places belong together:
run it →set days to list of Monday, Tuesday, Wednesday set pages to list of 3, 7, 5 show the first of days show the first of pagesMondayand3— three pages read on Monday.Walk one list and take the same place out of the other.
with placesays where you are, and that place finds the partner:
run it →set days to list of Monday, Tuesday, Wednesday set pages to list of 3, 7, 5 for each day in days with place set read to item place of pages show day show read endThat number of blocks is the bar:
run it →set block to * set read to 7 set bar to block repeated read times show barSeven
*.The whole thing, ending with the busiest day's number:
run it →set days to list of Monday, Tuesday, Wednesday set pages to list of 3, 7, 5 set block to * for each day in days with place set read to item place of pages set bar to block repeated read times show day show bar end show the biggest of pagesYou can see Tuesday is the longest without reading a single number.
Try it yourself
Add another day and another number — to both lists, or the places stop lining up and the program stops at the place with no partner. Keeping a name and its number together in one place is what guide 41 is for.
What you learned
- Two lists side by side pair a name with a number.
with placesays where you are;item <place> of <list>takes the partner out.<block> repeated <n> timesturns that number into one bar.- Seen as lengths, the biggest is obvious without reading any number.