needmoreeasy EN 한국어
Learn

34 — Chart: seeing numbers as bars

★★★☆☆ (3/5)screen and time
Prerequisites
21 — Progress, 20 — ASCII art
You will end up with
drawing how much was read each day as bars, so the days compare at a glance

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

  1. Keep two lists side by side. One holds the names, the other the numbers, and the same places belong together:

    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 pages
    
    run it →

    Monday and 3 — three pages read on Monday.

  2. Walk one list and take the same place out of the other. with place says where you are, and that place finds the partner:

    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
    end
    
    run it →
  3. That number of blocks is the bar:

    set block to *
    set read to 7
    set bar to block repeated read times
    show bar
    
    run it →

    Seven *.

  4. The whole thing, ending with the busiest day's number:

    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 pages
    
    run it →

    You 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 place says where you are; item <place> of <list> takes the partner out.
  • <block> repeated <n> times turns that number into one bar.
  • Seen as lengths, the biggest is obvious without reading any number.

This page on GitHub