programlibs/Grouping/demos/sales.xtl

A month of sales: totals, averages and the best sale per region, set as a table, and the totals as bars. Run with "just demo Grouping sales".

source · imports gr: libs/Grouping/src/Grouping.xtl; f: libs/Format/src/Format.xtl; p: libs/Plot/src/Plot.xtl

region : Box Char

value · line 9
region ← "north" "south" "east" "north" "west" "east" "south" "north" "east" "west"

amount : Int

value · line 10
amount ← 120 340 95 210 180 60 400 75 150 220

regions : Box Char

value · line 12
regions ← u̲nique region

n : Int

value · line 13
n ← t̲ally regions
Used in: cells

cells : Box Char

value · line 14
cells ← ((n c̲at 1) r̲eshape regions) c̲at₂ ((n c̲at 1) r̲eshape 'f̲ormat m̲ap ᵍʳc̲ount region) c̲at₂ ((n c̲at 1) r̲eshape ᶠt̲housands region ᵍʳs̲um amount) c̲at₂ ((n c̲at 1) r̲eshape 1 ᶠf̲ixed region ᵍʳm̲ean amount) c̲at₂ (n c̲at 1) r̲eshape ᶠt̲housands region ᵍʳg̲reatest amount