user
Cistercian numerals were used across Europe by Cistercian monks during the Late Medieval Period as an alternative to Roman numerals. They were used to represent base 10 integers from **0** to **9999**.

How they work

All Cistercian numerals begin with a vertical line segment, which by itself represents the number **0**. Then, glyphs representing the digits **1** through **9** are optionally added to the four quadrants surrounding the vertical line segment. These glyphs are drawn with vertical and horizontal symmetry about the initial line segment. Each quadrant corresponds to a digit place in the number:

:   * The **upper-right** quadrant represents the **ones** place.
    * The **upper-left** quadrant represents the **tens** place.
    * The **lower-right** quadrant represents the **hundreds** place.
    * The **lower-left** quadrant represents the **thousands** place.

Please consult the following image for examples of Cistercian numerals showing each glyph: [1]

Task

:   * Write a function/procedure/routine to display any given Cistercian numeral. This could be done by drawing to the display, creating an image, or even as text (as long as it is a reasonable facsimile).

:   * Use the routine to show the following Cistercian numerals:

:   :   * 0
        * 1
        * 20
        * 300
        * 4000
        * 5555
        * 6789
        * And a number of your choice!

Notes

Due to the inability to upload images to Rosetta Code as of this task's creation, showing output here on this page is not required. However, it is welcomed — especially for text output.

See also

:   * **Numberphile - The Forgotten Number System**
    * **dcode.fr - Online Cistercian numeral converter**
assistant
Handles 0 through 9999 only. No error trapping. If you feed it an unsupported number it will truncate to maximum 4 digits.

```
my @line-segments = (0, 0, 0, 100),
    (0,  0, 35,  0), (0, 35, 35, 35), (0,  0, 35, 35), (0, 35, 35,  0), ( 35,  0, 35, 35),
    (0,  0,-35,  0), (0, 35,-35, 35), (0,  0,-35, 35), (0, 35,-35,  0), (-35,  0,-35, 35),
    (0,100, 35,100), (0, 65, 35, 65), (0,100, 35, 65), (0, 65, 35,100), ( 35, 65, 35,100),
    (0,100,-35,100), (0, 65,-35, 65), (0,100,-35, 65), (0, 65,-35,100), (-35, 65,-35,100);

my @components = map {@line-segments[$_]}, |((0, 5, 10, 15).map: -> $m {
    |((0,), (1,), (2,), (3,), (4,), (1,4), (5,), (1,5), (2,5), (1,2,5)).map: {$_ »+» $m}
});

my $out = 'Cistercian-raku.svg'.IO.open(:w);

$out.say: # insert header
q|<svg  width="875" height="470" style="stroke:black;" version="1.1" xmlns="http://www.w3.org/2000/svg">
 <rect width="100%" height="100%" style="fill:white;"/>|;

my $hs = 50; # horizontal spacing
my $vs = 25; # vertical spacing

for flat ^10, 20, 300, 4000, 5555, 6789, 9394, (^10000).pick(14) -> $cistercian {

    $out.say: |@components[0].map: { # draw zero / base vertical bar
        qq|<line x1="{.[0] + $hs}" y1="{.[1] + $vs}" x2="{.[2] + $hs}" y2="{.[3] + $vs}"/>|
    };

    my @orders-of-magnitude = $cistercian.polymod(10 xx *);

    for @orders-of-magnitude.kv -> $order, $value {
        next unless $value; # skip zeros, already drew zero bar
        last if $order > 3; # truncate too large integers

        # draw the component line segments
        $out.say: join "\n", @components[$order * 10 + $value].map: {
            qq|<line x1="{.[0] + $hs}" y1="{.[1] + $vs}" x2="{.[2] + $hs}" y2="{.[3] + $vs}"/>|
        }
    }

    # insert the decimal number below
    $out.say: qq|<text x="{$hs - 5}" y="{$vs + 120}">{$cistercian}</text>|;

    if ++$ %% 10 { # next row
        $hs = -35;
        $vs += 150;
    }

    $hs += 85; # increment horizontal spacing


}
$out.say: q|</svg>|; # insert footer

```

Output: