sourcelibs/Grouping/demos/sales.xtl

1⍝!/usr/bin/env xetal 2⍝# A month of sales: totals, averages and the best sale per region, 3⍝# set as a table, and the totals as bars. 4⍝# Run with "just demo Grouping sales". 5 6ᵍʳ⁼u̲se< "Grouping" 7ᶠ⁼u̲se< "Format" 8ᵖ⁼u̲se< "Plot" 9region ← "north" "south" "east" "north" "west" "east" "south" "north" "east" "west" 10amount ← 120 340 95 210 180 60 400 75 150 220 11 12regions ← u̲nique region 13n ← t̲ally regions 14cells ← ((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 15ᶠt̲able ("region" "sales" "total" "average" "best") c̲at cells 16 17regions ᵖb̲ars region ᵍʳs̲um amount