Cistercian numerals: Difference between revisions

m
→‎{{header|jq}}: <pre style="height:20lh;overflow:auto>
mNo edit summary
m (→‎{{header|jq}}: <pre style="height:20lh;overflow:auto>)
 
(35 intermediate revisions by 14 users not shown)
Line 34:
:* '''[https://www.youtube.com/watch?v=9p55Qgt7Ciw Numberphile - The Forgotten Number System]'''
:* '''[https://www.dcode.fr/cistercian-numbers dcode.fr - Online Cistercian numeral converter]'''
=={{header|68000 Assembly}}==
This Sega Genesis cartridge can be compiled with VASM and run in the Fusion emulator.
<syntaxhighlight lang="68000devpac">;CONSTANTS
VFLIP equ %0001000000000000
HFLIP equ %0000100000000000
;Ram Variables
Cursor_X equ $00FF0000
Cursor_Y equ Cursor_X+1
temp_cursor_x equ $00FF0002
temp_cursor_y equ $00FF0003
;Video Ports
VDP_data EQU $C00000 ; VDP data, R/W word or longword access only
VDP_ctrl EQU $C00004 ; VDP control, word or longword writes only
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Traps
DC.L $FFFFFE00 ;SP register value
DC.L ProgramStart ;Start of Program Code
DS.L 7,IntReturn ; bus err,addr err,illegal inst,divzero,CHK,TRAPV,priv viol
DC.L IntReturn ; TRACE
DC.L IntReturn ; Line A (1010) emulator
DC.L IntReturn ; Line F (1111) emulator
DS.L 4,IntReturn ; Reserverd /Coprocessor/Format err/ Uninit Interrupt
DS.L 8,IntReturn ; Reserved
DC.L IntReturn ; spurious interrupt
DC.L IntReturn ; IRQ level 1
DC.L IntReturn ; IRQ level 2 EXT
DC.L IntReturn ; IRQ level 3
DC.L IntReturn ; IRQ level 4 Hsync
DC.L IntReturn ; IRQ level 5
DC.L IntReturn ; IRQ level 6 Vsync
DC.L IntReturn ; IRQ level 7
DS.L 16,IntReturn ; TRAPs
DS.L 16,IntReturn ; Misc (FP/MMU)
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Header
DC.B "SEGA GENESIS " ;System Name
DC.B "(C)CHBI " ;Copyright
DC.B "2019.JAN" ;Date
DC.B "ChibiAkumas.com " ; Cart Name
DC.B "ChibiAkumas.com " ; Cart Name (Alt)
DC.B "GM CHIBI001-00" ;TT NNNNNNNN-RR T=Type (GM=Game) N=game Num R=Revision
DC.W $0000 ;16-bit Checksum (Address $000200+)
DC.B "J " ;Control Data (J=3button K=Keyboard 6=6button C=cdrom)
DC.L $00000000 ;ROM Start
DC.L $003FFFFF ;ROM Length
DC.L $00FF0000,$00FFFFFF ;RAM start/end (fixed)
DC.B " " ;External RAM Data
DC.B " " ;Modem Data
DC.B " " ;MEMO
DC.B "JUE " ;Regions Allowed
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Generic Interrupt Handler
IntReturn:
rte
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Program Start
ProgramStart:
;initialize TMSS (TradeMark Security System)
move.b ($A10001),D0 ;A10001 test the hardware version
and.b #$0F,D0
beq NoTmss ;branch if no TMSS chip
move.l #'SEGA',($A14000);A14000 disable TMSS
NoTmss:
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Set Up Screen Settings
 
lea VDPSettings,A5 ;Initialize Screen Registers
move.l #VDPSettingsEnd-VDPSettings,D1 ;length of Settings
move.w (VDP_ctrl),D0 ;C00004 read VDP status (interrupt acknowledge?)
move.l #$00008000,d5 ;VDP Reg command (%8rvv)
NextInitByte:
move.b (A5)+,D5 ;get next video control byte
move.w D5,(VDP_ctrl) ;C00004 send write register command to VDP
; 8RVV - R=Reg V=Value
add.w #$0100,D5 ;point to next VDP register
dbra D1,NextInitByte ;loop for rest of block
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Set up palette and graphics
move.l #$C0000000,d0 ;Color 0
move.l d0,VDP_Ctrl
MOVE.W #$0A00,VDP_Data ;BLUE
move.l #$C01E0000,d0 ;Color 0
move.l d0,VDP_Ctrl
MOVE.W #$00EE,VDP_Data ;YELLOW
lea Graphics,a0 ;background tiles
move.w #(GraphicsEnd-Graphics)-1,d1 ;data size
MOVEQ #0,D2 ;start loading at tile 0 of VRAM
jsr DefineTiles
;Turn on screen
move.w #$8144,(VDP_Ctrl);C00004 reg 1 = 0x44 unblank display
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Main:
CLR.B Cursor_X
CLR.B Cursor_Y
LEA TestData,a3
jsr PrintCistercian
jsr PrintCistercian
jsr PrintCistercian
jsr PrintCistercian
jsr PrintCistercian
jsr PrintCistercian
jsr PrintCistercian
jsr PrintCistercian
jmp * ;halt the cpu - we're done
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintCistercian:
;input:A3 = address of test data.
MOVE.B Cursor_X,temp_Cursor_X
MOVE.B Cursor_Y,temp_Cursor_Y
MOVE.L (A3)+,D1
;thousands, hundreds, tens, ones
;PRINT TENS PLACE
MOVE.L D1,D0
ROR.W #8,D0 ;get tens place into low byte
AND.W #$FF,D0
OR.W #HFLIP,D0
jsr doPrint
addq.b #1,(Cursor_X) ;INC Xpos
;PRINT ONES PLACE
MOVE.L D1,D0
AND.W #$FF,D0
JSR doPrint
MOVE.B temp_Cursor_X,Cursor_X
ADDQ.B #1,cursor_Y
;PRINT STICK CENTER
MOVE.W #10,D0 ;the center of the stick
OR.W #HFLIP,D0
jsr doPrint
addq.b #1,(Cursor_X) ;INC Xpos
MOVE.W #10,D0 ;the center of the stick
jsr doPrint
MOVE.B temp_Cursor_X,Cursor_X
ADDQ.B #1,cursor_Y
;PRINT THOUSANDS PLACE
MOVE.L D1,D0
SWAP D0
ROR.W #8,D0 ;get thousands place into low byte
AND.W #$FF,D0
OR.W #(HFLIP|VFLIP),D0
jsr doPrint
addq.b #1,(Cursor_X) ;INC Xpos
MOVE.L D1,D0
SWAP D0
AND.W #$FF,D0
OR.W #(VFLIP),D0
jsr doPrint
MOVE.B temp_Cursor_X,Cursor_X
MOVE.B temp_Cursor_Y,Cursor_Y
ADDQ.B #3,Cursor_X
rts
doPrint:
;;; this code outputs the tile index in D0 to the Genesis's tilemap... don't worry if it doesn't make sense!
Move.L #$40000003,d5
clr.l d4
 
Move.B (Cursor_Y),D4
rol.L #8,D4
rol.L #8,D4
rol.L #7,D4
add.L D4,D5
Move.B (Cursor_X),D4
rol.L #8,D4
rol.L #8,D4
rol.L #1,D4
add.L D4,D5
MOVE.L D5,(VDP_ctrl)
MOVE.W D0,(VDP_data)
rts
TestData:
;I used 10 for zero since otherwise we'd have a bunch of sticks as the blank tile... not good!
DC.B 10,10,10,10
DC.B 10,10,10,1
DC.B 10,10,2,10
DC.B 10,3,10,10
DC.B 4,10,10,10
DC.B 5,5,5,5
DC.B 6,7,8,9
DC.B 1,2,3,4
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
DefineTiles: ;Copy D1 bytes of data from A0 to VDP memory D2
jsr prepareVram ;Calculate the memory location we want to write
.again: ; the tile pattern definitions to
move.l (a0)+,(VDP_data)
dbra d1,.again
rts
prepareVram:
;input: D2 = the vram memory address you want to write to.
;To select a memory location D2 we need to calculate
;the command byte... depending on the memory location
MOVEM.L D0-D7/A0-A6,-(SP) ;$7FFF0003 = Vram $FFFF.... $40000000=Vram $0000
move.l d2,d0
and.w #%1100000000000000,d0 ;Shift the top two bits to the far right
rol.w #2,d0
and.l #%0011111111111111,d2 ; shift all the other bits left two bytes
rol.l #8,d2
rol.l #8,d2
or.l d0,d2
or.l #$40000000,d2 ;Set the second bit from the top to 1
;#%01000000 00000000 00000000 00000000
move.l d2,(VDP_ctrl)
MOVEM.L (SP)+,D0-D7/A0-A6
rts
Graphics:
;cistercian numerals
DC.L 0,0,0,0,0,0,0,0 ;padding - this determines the default background tile.
dc.l $FFFFFFFF,$F0000000,$F0000000,$F0000000,$F0000000,$F0000000,$F0000000,$F0000000 ;1
dc.l $F0000000,$F0000000,$F0000000,$F0000000,$FFFFFFFF,$F0000000,$F0000000,$F0000000 ;2
dc.l $FF000000,$F0F00000,$F00F0000,$F000F000,$F0000F00,$F00000F0,$F000000F,$F0000000 ;3
dc.l $F0000000,$F000000F,$F00000F0,$F0000F00,$F000F000,$F00F0000,$F0F00000,$FF000000 ;4
dc.l $FFFFFFFF,$F00000F0,$F0000F00,$F000F000,$F00F0000,$F0F00000,$FF000000,$F0000000 ;5
dc.l $F000000F,$F000000F,$F000000F,$F000000F,$F000000F,$F000000F,$F000000F,$F000000F ;6
dc.l $FFFFFFFF,$F000000F,$F000000F,$F000000F,$F000000F,$F000000F,$F000000F,$F000000F ;7
dc.l $F000000F,$F000000F,$F000000F,$F000000F,$F000000F,$F000000F,$F000000F,$FFFFFFFF ;8
dc.l $FFFFFFFF,$F000000F,$F000000F,$F000000F,$F000000F,$F000000F,$F000000F,$FFFFFFFF ;9
DC.L $F0000000,$F0000000,$F0000000,$F0000000,$F0000000,$F0000000,$F0000000,$F0000000 ;the "stick"
GraphicsEnd:
VDPSettings:
DC.B $04 ; 0 mode register 1 ---H-1M-
DC.B $04 ; 1 mode register 2 -DVdP---
DC.B $30 ; 2 name table base for scroll A (A=top 3 bits) --AAA--- = $C000
DC.B $3C ; 3 name table base for window (A=top 4 bits / 5 in H40 Mode) --AAAAA- = $F000
DC.B $07 ; 4 name table base for scroll B (A=top 3 bits) -----AAA = $E000
DC.B $6C ; 5 sprite attribute table base (A=top 7 bits / 6 in H40) -AAAAAAA = $D800
DC.B $00 ; 6 unused register --------
DC.B $00 ; 7 background color (P=Palette C=Color) --PPCCCC
DC.B $00 ; 8 unused register --------
DC.B $00 ; 9 unused register --------
DC.B $FF ;10 H interrupt register (L=Number of lines) LLLLLLLL
DC.B $00 ;11 mode register 3 ----IVHL
DC.B $81 ;12 mode register 4 (C bits both1 = H40 Cell) C---SIIC
DC.B $37 ;13 H scroll table base (A=Top 6 bits) --AAAAAA = $FC00
DC.B $00 ;14 unused register --------
DC.B $02 ;15 auto increment (After each Read/Write) NNNNNNNN
DC.B $01 ;16 scroll size (Horiz & Vert size of ScrollA & B) --VV--HH = 64x32 tiles
DC.B $00 ;17 window H position (D=Direction C=Cells) D--CCCCC
DC.B $00 ;18 window V position (D=Direction C=Cells) D--CCCCC
DC.B $FF ;19 DMA length count low LLLLLLLL
DC.B $FF ;20 DMA length count high HHHHHHHH
DC.B $00 ;21 DMA source address low LLLLLLLL
DC.B $00 ;22 DMA source address mid MMMMMMMM
DC.B $80 ;23 DMA source address high (C=CMD) CCHHHHHH
VDPSettingsEnd:
even</syntaxhighlight>
 
{{out}}
[https://ibb.co/Fz11L4w Screenshot of emulator]
=={{header|Action!}}==
<syntaxhighlight lang="action!">BYTE FUNC AtasciiToInternal(CHAR c)
BYTE c2
 
c2=c&$7F
IF c2<32 THEN RETURN (c+64)
ELSEIF c2<96 THEN RETURN (c-32) FI
RETURN (c)
 
PROC CharOut(CARD x BYTE y CHAR c)
BYTE i,j,v
CARD addr
 
addr=$E000+AtasciiToInternal(c)*8
FOR j=0 TO 7
DO
v=Peek(addr) i=8
WHILE i>0
DO
IF (v&1)=0 THEN Color=0
ELSE Color=1 FI
Plot(x+i,y+j)
v=v RSH 1 i==-1
OD
addr==+1
OD
RETURN
 
PROC TextOut(CARD x BYTE y CHAR ARRAY text)
BYTE i
 
FOR i=1 TO text(0)
DO
CharOut(x,y,text(i))
x==+8
OD
RETURN
 
PROC DrawDigit(BYTE d INT x BYTE y INT dx,dy)
IF d=1 THEN
Plot(x,y) DrawTo(x+dx,y)
ELSEIF d=2 THEN
Plot(x,y+dy) DrawTo(x+dx,y+dy)
ELSEIF d=3 THEN
Plot(x,y) DrawTo(x+dx,y+dy)
ELSEIF d=4 THEN
Plot(x,y+dy) DrawTo(x+dx,y)
ELSEIF d=5 THEN
Plot(x,y) DrawTo(x+dx,y) DrawTo(x,y+dy)
ELSEIF d=6 THEN
Plot(x+dx,y) DrawTo(x+dx,y+dy)
ELSEIF d=7 THEN
Plot(x,y) DrawTo(x+dx,y) DrawTo(x+dx,y+dy)
ELSEIF d=8 THEN
Plot(x,y+dy) DrawTo(x+dx,y+dy) DrawTo(x+dx,y)
ELSEIF d=9 THEN
Plot(x,y) DrawTo(x+dx,y)
DrawTo(x+dx,y+dy) DrawTo(x,y+dy)
FI
RETURN
 
PROC Cystersian(CARD n INT x BYTE y,s)
INT ms
 
ms=-s
Color=1
Plot(x+s,y) DrawTo(x+s,y+3*s)
 
DrawDigit(n MOD 10,x+s,y,s,s)
n==/10
DrawDigit(n MOD 10,x+s,y,ms,s)
n==/10
DrawDigit(n MOD 10,x+s,y+3*s,s,ms)
n==/10
DrawDigit(n MOD 10,x+s,y+3*s,ms,ms)
RETURN
 
PROC Test(CARD n INT x BYTE y,s)
CHAR ARRAY text(5)
 
StrC(n,text)
TextOut(x+(2*s-text(0)*8)/2,y-10,text)
Cystersian(n,x,y,s)
RETURN
 
PROC Main()
CARD ARRAY numbers=[0 1 20 300 4000 5555 6789 6502 1977 2021]
BYTE CH=$02FC,COLOR1=$02C5,COLOR2=$02C6
BYTE s=[16],i
INT x,y
 
Graphics(8+16)
COLOR1=$0C
COLOR2=$02
 
x=s y=2*s
FOR i=0 TO 9
DO
Test(numbers(i),x,y,s)
x==+4*s
IF x>=320-s THEN
x=s y==+5*s
FI
OD
 
DO UNTIL CH#$FF OD
CH=$FF
RETURN</syntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Cistercian_numerals.png Screenshot from Atari 8-bit computer]
=={{header|ALGOL 68}}==
<syntaxhighlight lang="algol68">
BEGIN # draw some Cistercian Numerals #
 
INT ch = 6; # height of the representation of a Cistercian Numeral #
INT cw = 5; # width of the representation of a Cistercian Numeral #
INT cm = ( cw + 1 ) OVER 2; # mid-point of a line in the representation #
# of a Cistercian Numeral #
# returns a 5x6 CHAR array representing the Cistercian Nuneral of n #
# 0 <= m <= 9999 must be TRUE #
OP TOCISTERCIAN = ( INT n )[,]CHAR:
IF n < 0 OR n > 9999 THEN # invalid n #
( "?????", "?????", "?????", "?????", "?????", "?????" )
ELSE # n is OK #
# if ch isn't 6 or cw isn't 5, the strinngs above and below will #
[ 1 : ch, 1 : cw ]CHAR cn := # need to be adjusted #
( " ", " | ", " | ", " | ", " | ", " | " );
[]STRING t digits = ( #1# "__", #2# ";;__", #3# "; /;/"
, #4# ";\; \", #5# "__; /;/", #6# "; |; |"
, #7# "_; |; |", #8# "; |;_|", #9# "_; |;_|"
);
[]STRING b digits = ( #1# "__", #2# ";;__", #3# "\; \"
, #4# " /;/", #5# "_/;/", #6# " |; |"
, #7# "_|; |", #8# " |; |;_", #9# "_|; |;_"
);
# adds 1 digit to the numeral #
PROC add digit = ( INT digit, BOOL flip horizontal, flip vertical )VOID:
IF digit > 0 THEN # have a visible digit #
STRING d = IF flip vertical THEN b digits[ digit ] ELSE t digits[ digit ] FI;
INT x := IF flip horizontal THEN -1 ELSE 1 FI + cm;
INT y := IF flip vertical THEN ch ELSE 1 FI;
INT x init = x;
INT x step = IF flip horizontal THEN -1 ELSE 1 FI;
INT y step = IF flip vertical THEN -1 ELSE 1 FI;
FOR c pos FROM LWB d TO UPB d DO
CHAR c = d[ c pos ];
IF c = ";" THEN
y +:= y step;
x := x init
ELSE
cn[ y, x ] := IF ( flip horizontal XOR flip vertical ) THEN
IF c = "/" THEN "\" ELIF c = "\" THEN "/" ELSE c FI
ELSE c
FI;
x +:= x step
FI
OD
FI # add digit # ;
INT v := n;
add digit( v MOD 10, FALSE, FALSE ); v OVERAB 10;
add digit( v MOD 10, TRUE, FALSE ); v OVERAB 10;
add digit( v MOD 10, FALSE, TRUE ); v OVERAB 10;
add digit( v MOD 10, TRUE, TRUE );
cn
FI # TOCISTERCIAN # ;
# inserts a Cistercian Numeral representation of n into an set of lines #
PROC insert cistercian = ( [,]CHAR cn, REF[]STRING lines, INT pos )VOID:
FOR i FROM 1 TO ch DO
lines[ i ][ pos : ( pos + cw ) - 1 ] := STRING( cn[ i, : ] )
OD # print cistercian # ;
 
[]INT tests = ( 0, 20, 300, 4000, 5555, 6789, 1968 );
# construct an array of blank lines and insert the Cistercian Numereals #
[ 1 : ch ]STRING lines; # into them #
FOR i FROM LWB lines TO UPB lines DO
lines[ i ] := " " * ( ( ( UPB tests -LWB tests ) + 1 ) * ( cw * 2 ) )
OD;
FOR i FROM LWB tests TO UPB tests DO print( ( whole( tests[ i ], - cw ), " " * cw ) ) OD;
print( ( newline ) );
INT i pos := 1 - ( cw * 2 );
FOR i FROM LWB tests TO UPB tests DO
insert cistercian( TOCISTERCIAN tests[ i ], lines, i pos +:= cw * 2 )
OD;
FOR i FROM LWB lines TO UPB lines DO print( ( lines[ i ], newline ) ) OD
END
</syntaxhighlight>
{{out}}
<pre>
0 20 300 4000 5555 6789 1968
__ __ _
| | | | \ | / | | | | | |
| __| | | \|/ |_|_| | |_|
| | | | | | |_
| | | / /| /|\ | | | | |
| | |/ / | /_|_\ | |_| __|_|
</pre>
 
=={{header|AutoHotkey}}==
<syntaxhighlight lang="autohotkey">CistercianNumerals(num){
x := []
;UPPER LEFT 0 1 2 3 4 5 6 7 8 9
x[1, "UL"] := ["000","111","000","000","100","111","100","111","100","111"]
x[2, "UL"] := ["000","000","000","001","010","010","100","100","100","100"]
x[3, "UL"] := ["000","000","000","010","001","001","100","100","100","100"]
x[4, "UL"] := ["000","000","111","100","000","000","100","100","111","111"]
 
;UPPER RIGHT 0 1 2 3 4 5 6 7 8 9
x[1, "UR"] := ["000","111","000","000","001","111","001","111","001","111"]
x[2, "UR"] := ["000","000","000","100","010","010","001","001","001","001"]
x[3, "UR"] := ["000","000","000","010","100","100","001","001","001","001"]
x[4, "UR"] := ["000","000","111","001","000","000","001","001","111","111"]
 
;BOTTOM LEFT 0 1 2 3 4 5 6 7 8 9
x[1, "BL"] := ["000","000","111","100","000","000","100","100","111","111"]
x[2, "BL"] := ["000","000","000","010","001","001","100","100","100","100"]
x[3, "BL"] := ["000","000","000","001","010","010","100","100","100","100"]
x[4, "BL"] := ["000","111","000","000","100","111","100","111","100","111"]
 
;BOTTOM RIGHT 0 1 2 3 4 5 6 7 8 9
x[1, "BR"] := ["000","000","111","001","000","000","001","001","111","111"]
x[2, "BR"] := ["000","000","000","010","100","100","001","001","001","001"]
x[3, "BR"] := ["000","000","000","100","010","010","001","001","001","001"]
x[4, "BR"] := ["000","111","000","000","001","111","001","111","001","111"]
 
num := SubStr("0000" num, -3)
n := StrSplit(num) ; n.1*1000 + n.2*100 + n.3*10 + n.4
loop 4
res .= x[A_Index, "UL", 1+n.3] . "1" . x[A_Index, "UR", 1+n.4] . "`n"
loop 4
res .= "0001`n"
loop 4
res .= x[A_Index, "BL", 1+n.1] . "1" . x[A_Index, "BR", 1+n.2] . "`n"
res := StrReplace(res, 0, " ")
res := StrReplace(res, 1, "#")
return Trim(res, "`n")
}</syntaxhighlight>
Examples:<syntaxhighlight lang="autohotkey">Gui, font, S24, Consolas
Gui, add, Text, vE1 w150 r12
Gui, show, x0 y0
for i, num in [0, 1, 20, 300, 4000, 5555, 6789, 2022]
{
GuiControl,, E1, % CistercianNumerals(num)
MsgBox % num
}
return</syntaxhighlight>
{{out}}
<pre> 0 1 20 300 4000 5555 6789 2022
 
   #       ####    #       #       #    ####### #  ####    #   
   #       #       #       #       #     # # #  #  #  #    #   
   #       #       #       #       #      ###   #  #  #    #   
   #       #    ####       #       #       #    ####### #######
   #    #    #    #    #    #    #    #
   #    #    #    #    #    #    #    #
   #    #    #    #    #    #    #    #
   #    #    #    #    #    #    #    #
   #       #       #       #  #    #       #    #  #  # ####   
   #       #       #       # #    ##      ###   #  #  #    #   
   #       #       #       ##    # #     # # #  #  #  #    #   
   #       #       #       #    #  #    ####### #  ####    #   </pre>
 
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f CISTERCIAN_NUMERALS.AWK [-v debug={0|1}] [-v xc=anychar] numbers 0-9999 ...
#
Line 111 ⟶ 651:
if (debug == 1) { printf("%s\n",header) }
}
</syntaxhighlight>
</lang>
{{out}}
<pre style="height: 60ex; overflow: scroll">
Line 254 ⟶ 794:
invalid
</pre>
 
=={{header|C}}==
{{trans|C#}}
<langsyntaxhighlight lang="c">#include <stdio.h>
 
#define GRID_SIZE 15
Line 503 ⟶ 1,042:
 
return 0;
}</langsyntaxhighlight>
{{out}}
<pre>0:
Line 647 ⟶ 1,186:
x x x
xxxxxxxxxxx</pre>
 
=={{header|C++}}==
{{trans|Go}}
<langsyntaxhighlight lang="cpp">#include <array>
#include <iostream>
 
Line 904 ⟶ 1,442:
 
return 0;
}</langsyntaxhighlight>
{{out}}
<pre>0:
Line 1,041 ⟶ 1,579:
x x x
xxxxxxxxxxx</pre>
 
=={{header|D}}==
{{trans|Java}}
<langsyntaxhighlight lang="d">import std.stdio;
 
class Cistercian {
Line 1,255 ⟶ 1,792:
writeln(c);
}
}</langsyntaxhighlight>
{{out}}
<pre>0:
Line 1,391 ⟶ 1,928:
x x x
xxxxxxxxxxx</pre>
=={{header|EasyLang}}==
[https://easylang.dev/show/#cod=tZTBboMwDIbvPMUv7VZUFEJo6WFPUnEqVIvUJlOLOnj7Om6gBQbamMbBij/i33aC+bzYAw76WqFGA4MIUQDgpE35pYvqAyJKHSjqfY537KGwVg+TM286zrDlR3uBRmWhnMcCtI1UdN6CxoHmFUgiEitatYiAwdkWiIVHhlGhb090trfSle/dN/iFa4LbCpENtmLdoXaXd/WRs8befY0JXYlP7gND11r/ZXnyKnJCZU5kqJEsqWQoohYUMuom/YMIetfxjfhmJD5uZzZDp7RdcmC/Os1sIsMPNGaTdwl2/5QAE7fAM8+Gwujjl0EU1Nyom2MDbWjCBWJIgUQIKEEmpQebbbYjKpPH2Ps/SSZg+mp3 Run it]
 
<syntaxhighlight>
proc cist x y n . .
linewidth 0.5
dx[] = [ 4 -4 4 -4 ]
dy[] = [ 4 4 -4 -4 ]
for i to 4
dx = dx[i]
dy = dy[i]
dy2 = 2 * dy
d = n mod 10
n = n div 10
move x y
#
line x y + 8
move x y - 8
line x y
if d = 1
move x y + dy2
line x + dx y + dy2
elif d = 2
move x y + dy
line x + dx y + dy
elif d = 3
move x y + dy2
line x + dx y + dy
elif d = 4
move x y + dy
line x + dx y + dy2
elif d = 5
move x y + dy
line x + dx y + dy2
line x y + dy2
elif d = 6
move x + dx y + dy
line x + dx y + dy2
elif d = 7
move x y + dy2
line x + dx y + dy2
line x + dx y + dy
elif d = 8
move x y + dy
line x + dx y + dy
line x + dx y + dy2
elif d = 9
move x y + dy
line x + dx y + dy
line x + dx y + dy2
line x y + dy2
.
.
x += 12
.
x = 8
for n in [ 0 1 20 300 4000 5555 6789 2023 ]
cist x 80 n
x += 12
.
</syntaxhighlight>
 
=={{header|F_Sharp|F#}}==
<langsyntaxhighlight lang="fsharp">
// Cistercian numerals. Nigel Galloway: February 2nd., 2021
let N=[|[[|' ';' ';' '|];[|' ';' ';' '|];[|' ';' ';' '|]];
Line 1,411 ⟶ 2,009:
 
[(0,0,0,0);(0,0,0,1);(0,0,2,0);(0,3,0,0);(4,0,0,0);(5,5,5,5);(6,7,8,9)]|>List.iter(fun(i,g,e,l)->printfn "\n%d%d%d%d\n____" i g e l; fN i g e l)
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,487 ⟶ 2,085:
=={{header|Factor}}==
{{works with|Factor|0.99 2020-08-14}}
<langsyntaxhighlight lang="factor">USING: combinators continuations formatting grouping io kernel
literals math.order math.text.utils multiline sequences
splitting ;
Line 1,533 ⟶ 2,131:
with-datastack [ ] [ overwrite ] map-reduce [ print ] each ;
 
{ 0 1 20 300 4000 5555 6789 8015 } [ .cistercian nl ] each</langsyntaxhighlight>
{{out}}
<pre style="height: 60ex; overflow: scroll">
Line 1,608 ⟶ 2,206:
+ +
</pre>
 
=={{header|Fōrmulæ}}==
 
{{FormulaeEntry|page=https://formulae.org/?script=examples/Cistercian_numerals}}
 
'''Solution'''
 
We can take advantage of the coordinate transformations.
 
'''Part 1. Glyphs for each digit'''
 
The glyphs of each "digit" are the same, excepting they are mirrored according to its place ("units", "tens", "hundreds" and "thousands"), so we have generic code for each.
 
The following specification are for "units" and it is independent of size. They are referred to the top-right "quadrant" of the complete number, which has mathematical coordinate system, being (-1, -1) the bottom-left corner, and (1, 1) the opposite one, hence, the center is (0, 0).
 
Please notice that they are provided as an array of (9) lambda expressions. There is no glyph for zero.
 
[[File:Fōrmulæ - Cistercian numerals 01.png]]
 
'''Part 2. Mirroring for "tens", "hundreds" and "thousands"'''
 
The following is the specification to change the scale, according to the place and to produce the mirrored effect. Notice that there is no specification for "units", because the definitions of glyphs are based on this place and therefore there is no transformation to apply.
 
[[File:Fōrmulæ - Cistercian numerals 02.png]]
 
'''Part 3. Function to draw a Cistercian number'''
 
Finally, the following function creates the representation of the Cistercian number.
 
Notice that the origin is initially translated to the center of the graphics, and also is scaled to the size of the graphics too, in order to define the system of coordinates.
 
[[File:Fōrmulæ - Cistercian numerals 03.png]]
 
'''Test cases'''
 
[[File:Fōrmulæ - Cistercian numerals 04.png]]
 
[[File:Fōrmulæ - Cistercian numerals 05.png]]
 
'''Additional case. Creating all the Cistercian numerals in a single image'''
 
The following program creates a big image, and copies into it all the 10,000 different Cistercian numerals:
 
[[File:Fōrmulæ - Cistercian numerals 06.png]]
 
The result is a 4000 x 6010 pixels image. Click or tap on the following thumbnail to enlarge:
 
[[File:Fōrmulæ - Cistercian numerals 07.png|200px|link=https://static.miraheze.org/rosettacodewiki/c/c0/F%C5%8Drmul%C3%A6_-_Cistercian_numerals_07.png]]
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
_window = 1
begin enum 1
_numView
_numFld
end enum
 
_numHeight = 54
_lineLength = _numHeight/3
 
 
void local fn BuildWindow
window _window, @"Cistercian Numerals",, NSWindowStyleMaskTitled + NSWindowStyleMaskClosable + NSWindowStyleMaskMiniaturizable
subclass view _numView, (237,153,76,94)
ViewSetFlipped( _numView, YES )
textfield _numFld,, @"0", (237,20,76,21)
ControlSetAlignment( _numFld, NSTextAlignmentCenter )
ControlSetFormat( _numFld, @"0123456789", YES, 4, 0 )
WindowMakeFirstResponder( _window, _numFld )
end fn
 
 
void local fn PathDraw( path as BezierPathRef, lines as CFStringRef, x as CGFloat, y as CGFloat )
CGPoint pt1, pt2
long i
for i = 0 to 4
if ( intval(mid(lines,i,1)) )
select ( i )
case 0
pt1 = fn CGPointMake( x + _lineLength, y )
pt2 = fn CGPointMake( x + _lineLength, y + _lineLength )
case 1
pt1 = fn CGPointMake( x, y + _lineLength )
pt2 = fn CGPointMake( x + _lineLength, y )
case 2
pt1 = fn CGPointMake( x, y )
pt2 = fn CGPointMake( x + _lineLength, y + _lineLength )
case 3
pt1 = fn CGPointMake( x, y + _lineLength )
pt2 = fn CGPointMake( x + _lineLength, y + _lineLength )
case 4
pt1 = fn CGPointMake( x, y )
pt2 = fn CGPointMake( x + _lineLength, y )
end select
BezierPathMoveToPoint( path, pt1 )
BezierPathLineToPoint( path, pt2 )
end if
next
end fn
 
 
void local fn ViewDrawRect
CFArrayRef lines = @[@"00001",@"00010",@"00100",@"01000",@"01001",@"10000",@"10001",@"10010",@"10011"]
CFStringRef numString = fn ViewProperty( _numView, @"num" )
if ( numString )
CGFloat x = 38, y = 20
long i
for i = 0 to 3
BezierPathRef path = fn BezierPathWithRect( fn ViewBounds(_numView) )
BezierPathMoveToPoint( path, fn CGPointMake( x, y ) )
BezierPathLineToPoint( path, fn CGPointMake( x, y + _numHeight ) )
long num = intval( mid( numString, i, 1 ) )
if ( num )
fn PathDraw( path, lines[num-1], x, y )
if ( i < 3 )
CGFloat xScale = 1.0, yScale = 1.0
select ( i )
case 0 : xScale = -1.0 : yScale = -1.0 // 1000
case 1 : yScale = -1.0 // 100
case 2 : xScale = -1.0 // 10
end select
CGRect bounds = fn BezierPathBounds( path )
AffineTransformRef tx = fn AffineTransformInit
AffineTransformScaleXY( tx, xScale, yScale )
if ( xScale < 0.0 ) then AffineTransformTranslate( tx, -bounds.origin.x-bounds.size.width, 0.0 )
if ( yScale < 0.0 ) then AffineTransformTranslate( tx, 0.0, -bounds.size.height )
BezierPathTransformUsingAffineTranform( path, tx )
end if
end if
BezierPathStroke( path )
next
end if
end fn
 
 
void local fn DrawAction
CFStringRef string = fn StringWithFormat( @"%.4ld", fn ControlIntegerValue( _numFld ) )
ViewSetProperty( _numView, @"num", string )
ViewSetNeedsDisplay( _numView )
end fn
 
 
void local fn DoAppEvent( ev as long )
select ( ev )
case _appDidFinishLaunching
fn BuildWindow
fn DrawAction
case _appShouldTerminateAfterLastWindowClosed : AppEventSetBool(YES)
end select
end fn
 
 
void local fn DoDialog( ev as long, tag as long, wnd as long )
select ( ev )
case _btnClick
select ( tag )
case _numFld : fn DrawAction
end select
case _viewDrawRect
select ( tag )
case _numView : fn ViewDrawRect
end select
end select
end fn
 
 
on appevent fn DoAppEvent
on dialog fn DoDialog
 
HandleEvents
</syntaxhighlight>
[[File:CistercianNumeralsFB.png]]
 
=={{header|Go}}==
{{trans|Wren}}
<langsyntaxhighlight lang="go">package main
 
import "fmt"
Line 1,733 ⟶ 2,509:
printNumeral()
}
}</langsyntaxhighlight>
 
{{out}}
Line 1,739 ⟶ 2,515:
Same as Wren example.
</pre>
 
=={{header|J}}==
Program writes a scalable vector graphics file containing all composable numbers. J code is alongside the original python source.
Line 1,748 ⟶ 2,523:
</pre>
The <tt>rc</tt> verb writes <tt>RC=. 0 1 20 300 666 4000 5555 6789</tt>
<syntaxhighlight lang="j">
<lang J>
NB. http://rosettacode.org/wiki/Cistercian_numerals
NB. converted from
Line 1,930 ⟶ 2,705:
'open browser to {}{}{}' format~ (pwd'') ; PATHJSEP_j_ ; y
)
</syntaxhighlight>
</lang>
 
=={{header|Java}}==
{{trans|Kotlin}}
<langsyntaxhighlight lang="java">import java.util.Arrays;
import java.util.List;
 
Line 2,143 ⟶ 2,917:
}
}
}</langsyntaxhighlight>
{{out}}
<pre>0:
Line 2,280 ⟶ 3,054:
x x x
xxxxxxxxxxx </pre>
 
=={{header|JavaScript}}==
Using a canvas.
<syntaxhighlight lang="javascript">
<lang javaScript>
// html
document.write(`
Line 2,386 ⟶ 3,159:
}
}
</syntaxhighlight>
</lang>
{{out}}<pre>
https://jsfiddle.net/43tsmn9z</pre>
=={{header|jq}}==
'''Works with jq, the C implementation of jq'''
 
'''Works with gojq, the Go implementation of jq'''
 
'''Adapted from [[#Wren|Wren]]'''
<syntaxhighlight lang="jq">
### Generic function
# Replace whatever is at .[$i:$i+1] with $x.
# The input and $x should be of the same type - strings or arrays.
def replace($i; $x): .[:$i] + $x + .[$i+1:];
 
### Cistercian numerals
 
# The canvas: an array of strings
def canvas:
(" " * 11) as $row
| [range(0; 15) | $row | replace(5; "x")];
def horiz($c1; $c2; $r):
reduce range($c1; $c2+1) as $c (.; .[$r] |= replace($c; "x"));
 
def verti($r1; $r2; $c):
reduce range($r1; $r2+1) as $r (.; .[$r] |= replace($c; "x"));
 
def diagd($c1; $c2; $r):
reduce range($c1; $c2+1) as $c (.; .[$r+$c-$c1] |= replace($c;"x"));
 
def diagu($c1; $c2; $r):
reduce range($c1; $c2+1) as $c (.; .[$r-$c+$c1] |= replace($c; "x"));
 
# input: the canvas
def draw($n):
if $n == 0 then .
elif $n == 1 then horiz(6; 10; 0)
elif $n == 2 then horiz(6; 10; 4)
elif $n == 3 then diagd(6; 10; 0)
elif $n == 4 then diagu(6; 10; 4)
elif $n == 5 then draw(1) | draw(4)
elif $n == 6 then verti(0; 4; 10)
elif $n == 7 then draw(1) | draw(6)
elif $n == 8 then draw(2) | draw(6)
elif $n == 9 then draw(1) | draw(8)
elif $n == 10 then horiz(0; 4; 0)
elif $n == 20 then horiz(0; 4; 4)
elif $n == 30 then diagu(0; 4; 4)
elif $n == 40 then diagd(0; 4; 0)
elif $n == 50 then draw(10) | draw(40)
elif $n == 60 then verti(0; 4; 0)
elif $n == 70 then draw(10) | draw(60)
elif $n == 80 then draw(20) | draw(60)
elif $n == 90 then draw(10) | draw(80)
elif $n == 100 then horiz(6; 10; 14)
elif $n == 200 then horiz(6; 10; 10)
elif $n == 300 then diagu(6; 10; 14)
elif $n == 400 then diagd(6; 10; 10)
elif $n == 500 then draw(100) | draw(400)
elif $n == 600 then verti(10; 14; 10)
elif $n == 700 then draw(100) | draw(600)
elif $n == 800 then draw(200) | draw(600)
elif $n == 900 then draw(100) | draw(800)
elif $n == 1000 then horiz(0; 4; 14)
elif $n == 2000 then horiz(0; 4; 10)
elif $n == 3000 then diagd(0; 4; 10)
elif $n == 4000 then diagu(0; 4; 14)
elif $n == 5000 then draw(1000) | draw(4000)
elif $n == 6000 then verti(10; 14; 0)
elif $n == 7000 then draw(1000) | draw(6000)
elif $n == 8000 then draw(2000) | draw(6000)
elif $n == 9000 then draw(1000) | draw(8000)
else "unable to draw \(.)" | error
end;
 
def cistercian:
(./1000|floor) as $thousands
| (. % 1000) as $n
| ($n/100|floor) as $hundreds
| ($n % 100) as $n
| ($n/10|floor) as $tens
| ($n % 10) as $ones
| "\(.):",
( canvas
| draw($thousands*1000)
| draw($hundreds*100)
| draw($tens*10)
| draw($ones)
| .[] ),
"" ;
 
0, 1, 20, 300, 4000, 5555, 6789, 9999
| cistercian
</syntaxhighlight>
{{output}}
<pre style="height:20lh;overflow:auto>
0:
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
 
1:
xxxxxx
x
x
x
x
x
x
x
x
x
x
x
x
x
x
 
20:
x
x
x
x
xxxxxx
x
x
x
x
x
x
x
x
x
x
 
300:
x
x
x
x
x
x
x
x
x
x
x x
x x
x x
x x
xx
 
4000:
x
x
x
x
x
x
x
x
x
x
xx
x x
x x
x x
x x
 
5555:
xxxxxxxxxxx
x x x
x x x
x x x
xxx
x
x
x
x
x
xxx
x x x
x x x
x x x
xxxxxxxxxxx
 
6789:
x xxxxxx
x x x
x x x
x x x
xxxxxxxxxxx
x
x
x
x
x
x x x
x x x
x x x
x x x
x xxxxxx
 
9999:
xxxxxxxxxxx
x x x
x x x
x x x
xxxxxxxxxxx
x
x
x
x
x
xxxxxxxxxxx
x x x
x x x
x x x
xxxxxxxxxxx
 
</pre>
 
=={{header|Julia}}==
Gtk graphic version.
<langsyntaxhighlight lang="julia">using Gtk, Cairo
 
const can = GtkCanvas(800, 100)
Line 2,449 ⟶ 3,453:
 
mooncipher()
</syntaxhighlight>
</lang>
 
=={{header|Kotlin}}==
{{trans|C++}}
<langsyntaxhighlight lang="scala">import java.io.StringWriter
 
class Cistercian() {
Line 2,676 ⟶ 3,680:
}
 
}</langsyntaxhighlight>
{{out}}
<pre>0:
Line 2,813 ⟶ 3,817:
x x x
xxxxxxxxxxx </pre>
 
=={{header|Lua}}==
{{trans|Go}}
<langsyntaxhighlight lang="lua">function initN()
local n = {}
for i=1,15 do
Line 2,935 ⟶ 3,938:
end
 
main()</langsyntaxhighlight>
{{out}}
<pre>0:
Line 3,072 ⟶ 4,075:
x x x
x x x x x x x x x x x</pre>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">ClearAll[CistercianNumberEncodeHelper, CistercianNumberEncode]
\[Delta] = 0.25;
CistercianNumberEncodeHelper[0] := {}
Line 3,114 ⟶ 4,116:
CistercianNumberEncode[5555]
CistercianNumberEncode[6789]
CistercianNumberEncode[1337]</langsyntaxhighlight>
{{out}}
A set of Graphics is shown for each of the numerals.
 
=={{header|Nim}}==
{{trans|Kotlin}}
<langsyntaxhighlight Nimlang="nim">const Size = 15
 
type Canvas = array[Size, array[Size, char]]
Line 3,278 ⟶ 4,279:
for number in [0, 1, 20, 300, 4000, 5555, 6789, 9999]:
echo number, ':'
echo cistercian(number)</langsyntaxhighlight>
 
{{out}}
Line 3,417 ⟶ 4,418:
xxxxxxxxxxx
</pre>
=={{header|Perl}}==
<syntaxhighlight lang="perl">#!/usr/bin/perl
 
use strict; # https://rosettacode.org/wiki/Cistercian_numerals
=={{header|Phix}}==
use warnings;
<lang Phix>--
-- Define each digit as {up-down multiplier, left-right multiplier, char},
-- that is starting each drawing from line 1 or 7, column 3,
-- and with `/` and `\` being flipped below when necessary.
--
constant ds = {{{0,0,'+'},{0,1,'-'},{0,2,'-'}}, -- 1
{{2,0,'+'},{2,1,'-'},{2,2,'-'}}, -- 2
{{0,0,'+'},{1,1,'\\'},{2,2,'\\'}}, -- 3
{{2,0,'+'},{1,1,'/'},{0,2,'/'}}, -- 4
{{2,0,'+'},{1,1,'/'},{0,2,'+'},
{0,0,'+'},{0,1,'-'}}, -- 5
{{0,2,'|'},{1,2,'|'},{2,2,'|'}}, -- 6
{{0,0,'+'},{0,1,'-'},{0,2,'+'},
{1,2,'|'},{2,2,'|'}}, -- 7
{{2,0,'+'},{2,1,'-'},{2,2,'+'},
{1,2,'|'},{0,2,'|'}}, -- 8
{{2,0,'+'},{2,1,'-'},{2,2,'+'},
{1,2,'|'},{0,2,'+'},
{0,1,'-'},{0,0,'+'}}} -- 9
 
my @pts = ('', qw( 01 23 03 12 012 13 013 132 0132) );
function cdigit(sequence s, integer d, pos)
my @dots = qw( 4-0 8-0 4-4 8-4 );
--
-- s is our canvas, 7 lines of 5 characters
-- d is the digit, 0..9
-- pos is 4..1 for bl,br,tl,tr (easier to say/see 'backwards')
--
if d then
integer ud = {+1,+1,-1,-1}[pos],
lr = {+1,-1,+1,-1}[pos],
l = {1,1,7,7}[pos]
sequence dset = ds[d]
for i=1 to length(dset) do
integer {udm, lrm, ch} = dset[i],
tf = find(ch,`/\`)
if tf and ud!=lr then ch=`\/`[tf] end if
s[l+ud*udm][3+lr*lrm] = ch
end for
end if
return s
end function
 
my @images = map { sprintf("%-9s\n", "$_:") . draw($_) }
procedure cisterian(sequence n)
0, 1, 20, 300, 4000, 5555, 6789, 1133;
sequence res = {}
for ( 1 .. 13 )
for i=1 to length(n) do
{
integer cn = n[i]
s/(.+)\n/ print " $1"; '' /e for @images;
res = append(res,sprintf("%4d:",cn))
print "\n";
sequence s = repeat(" | ",7)
}
integer pos = 1
while cn do
s = cdigit(s, remainder(cn,10), pos)
pos += 1
cn = floor(cn/10)
end while
res &= s
end for
puts(1,join_by(res,8,10))
end procedure
 
sub draw
cisterian({0,1,2,3,4,5,6,7,8,9,20, 300, 4000, 5555, 6789, 9394, 7922, 9999})</lang>
{
my $n = shift;
local $_ = " # \n" x 12;
my $quadrant = 0;
for my $digit ( reverse split //, sprintf "%04d", $n )
{
my ($oldx, $oldy);
for my $cell ( split //, $pts[$digit] )
{
my ($x, $y) = split /-/, $dots[$cell];
if( defined $oldx )
{
my $dirx = $x <=> $oldx;
my $diry = $y <=> $oldy;
for my $place ( 0 .. 3 )
{
substr $_, $oldx + $oldy * 10, 1, '#';
$oldx += $dirx;
$oldy += $diry;
}
}
($oldx, $oldy) = ($x, $y);
}
s/.+/ reverse $& /ge;
++$quadrant & 1 or $_ = join '', reverse /.+\n/g;
}
return $_;
}</syntaxhighlight>
{{out}}
<pre>
0: 1: 20: 300: 4000: 5555: 6789: 1133:
# #### # # # ######### # ##### #
# # # # # # # # # # # ###
# # # # # # # # # # # # # #
# # # # # ### # # # # # #
# # #### # # # ######### #
# # # # # # # #
# # # # # # # #
# # # # # # # #
# # # # # ## ### # # # #
# # # # # # # # # # # # # #
# # # ## # # # # # # # # #
# # # # # # ######### # ##### #######
</pre>
=={{header|Phix}}==
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #000080;font-style:italic;">--
-- Define each digit as {up-down multiplier, left-right multiplier, char},
-- that is starting each drawing from line 1 or 7, column 3,
-- and with `/` and `\` being flipped below when necessary.
--</span>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">constant</span> <span style="color: #000000;">ds</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{{{</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'+'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'-'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'-'</span><span style="color: #0000FF;">}},</span> <span style="color: #000080;font-style:italic;">-- 1</span>
<span style="color: #0000FF;">{{</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'+'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'-'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'-'</span><span style="color: #0000FF;">}},</span> <span style="color: #000080;font-style:italic;">-- 2</span>
<span style="color: #0000FF;">{{</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'+'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'\\'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'\\'</span><span style="color: #0000FF;">}},</span> <span style="color: #000080;font-style:italic;">-- 3</span>
<span style="color: #0000FF;">{{</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'+'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'/'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'/'</span><span style="color: #0000FF;">}},</span> <span style="color: #000080;font-style:italic;">-- 4</span>
<span style="color: #0000FF;">{{</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'+'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'/'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'+'</span><span style="color: #0000FF;">},</span>
<span style="color: #0000FF;">{</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'+'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'-'</span><span style="color: #0000FF;">}},</span> <span style="color: #000080;font-style:italic;">-- 5</span>
<span style="color: #0000FF;">{{</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'|'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'|'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'|'</span><span style="color: #0000FF;">}},</span> <span style="color: #000080;font-style:italic;">-- 6</span>
<span style="color: #0000FF;">{{</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'+'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'-'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'+'</span><span style="color: #0000FF;">},</span>
<span style="color: #0000FF;">{</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'|'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'|'</span><span style="color: #0000FF;">}},</span> <span style="color: #000080;font-style:italic;">-- 7</span>
<span style="color: #0000FF;">{{</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'+'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'-'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'+'</span><span style="color: #0000FF;">},</span>
<span style="color: #0000FF;">{</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'|'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'|'</span><span style="color: #0000FF;">}},</span> <span style="color: #000080;font-style:italic;">-- 8</span>
<span style="color: #0000FF;">{{</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'+'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'-'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'+'</span><span style="color: #0000FF;">},</span>
<span style="color: #0000FF;">{</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'|'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'+'</span><span style="color: #0000FF;">},</span>
<span style="color: #0000FF;">{</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'-'</span><span style="color: #0000FF;">},{</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #008000;">'+'</span><span style="color: #0000FF;">}}}</span> <span style="color: #000080;font-style:italic;">-- 9</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">cdigit</span><span style="color: #0000FF;">(</span><span style="color: #004080;">sequence</span> <span style="color: #000000;">s</span><span style="color: #0000FF;">,</span> <span style="color: #004080;">integer</span> <span style="color: #000000;">d</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">pos</span><span style="color: #0000FF;">)</span>
<span style="color: #000080;font-style:italic;">--
-- s is our canvas, 7 lines of 5 characters
-- d is the digit, 0..9
-- pos is 4..1 for bl,br,tl,tr (easier to say/see 'backwards')
--</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">d</span> <span style="color: #008080;">then</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">ud</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,-</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,-</span><span style="color: #000000;">1</span><span style="color: #0000FF;">}[</span><span style="color: #000000;">pos</span><span style="color: #0000FF;">],</span>
<span style="color: #000000;">lr</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,-</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,-</span><span style="color: #000000;">1</span><span style="color: #0000FF;">}[</span><span style="color: #000000;">pos</span><span style="color: #0000FF;">],</span>
<span style="color: #000000;">l</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">7</span><span style="color: #0000FF;">,</span><span style="color: #000000;">7</span><span style="color: #0000FF;">}[</span><span style="color: #000000;">pos</span><span style="color: #0000FF;">]</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">dset</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">ds</span><span style="color: #0000FF;">[</span><span style="color: #000000;">d</span><span style="color: #0000FF;">]</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">dset</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span>
<span style="color: #004080;">integer</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">udm</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">lrm</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">ch</span><span style="color: #0000FF;">}</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">dset</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">],</span>
<span style="color: #000000;">tf</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">find</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ch</span><span style="color: #0000FF;">,</span><span style="color: #008000;">`/\`</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">tf</span> <span style="color: #008080;">and</span> <span style="color: #000000;">ud</span><span style="color: #0000FF;">!=</span><span style="color: #000000;">lr</span> <span style="color: #008080;">then</span> <span style="color: #000000;">ch</span><span style="color: #0000FF;">=</span><span style="color: #008000;">`\/`</span><span style="color: #0000FF;">[</span><span style="color: #000000;">tf</span><span style="color: #0000FF;">]</span> <span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #000000;">s</span><span style="color: #0000FF;">[</span><span style="color: #000000;">l</span><span style="color: #0000FF;">+</span><span style="color: #000000;">ud</span><span style="color: #0000FF;">*</span><span style="color: #000000;">udm</span><span style="color: #0000FF;">][</span><span style="color: #000000;">3</span><span style="color: #0000FF;">+</span><span style="color: #000000;">lr</span><span style="color: #0000FF;">*</span><span style="color: #000000;">lrm</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">ch</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">return</span> <span style="color: #000000;">s</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #008080;">procedure</span> <span style="color: #000000;">cisterian</span><span style="color: #0000FF;">(</span><span style="color: #004080;">sequence</span> <span style="color: #000000;">n</span><span style="color: #0000FF;">)</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">res</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{}</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">n</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">cn</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">n</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]</span>
<span style="color: #000000;">res</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">append</span><span style="color: #0000FF;">(</span><span style="color: #000000;">res</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">sprintf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%4d:"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">cn</span><span style="color: #0000FF;">))</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">s</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #008000;">" | "</span><span style="color: #0000FF;">,</span><span style="color: #000000;">7</span><span style="color: #0000FF;">)</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">pos</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span>
<span style="color: #008080;">while</span> <span style="color: #000000;">cn</span> <span style="color: #008080;">do</span>
<span style="color: #000000;">s</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">cdigit</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">,</span> <span style="color: #7060A8;">remainder</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cn</span><span style="color: #0000FF;">,</span><span style="color: #000000;">10</span><span style="color: #0000FF;">),</span> <span style="color: #000000;">pos</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">pos</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span>
<span style="color: #000000;">cn</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">floor</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cn</span><span style="color: #0000FF;">/</span><span style="color: #000000;">10</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<span style="color: #000000;">res</span> <span style="color: #0000FF;">&=</span> <span style="color: #000000;">s</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #7060A8;">puts</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">join_by</span><span style="color: #0000FF;">(</span><span style="color: #000000;">res</span><span style="color: #0000FF;">,</span><span style="color: #000000;">8</span><span style="color: #0000FF;">,</span><span style="color: #000000;">10</span><span style="color: #0000FF;">))</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<span style="color: #000000;">cisterian</span><span style="color: #0000FF;">({</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">3</span><span style="color: #0000FF;">,</span><span style="color: #000000;">4</span><span style="color: #0000FF;">,</span><span style="color: #000000;">5</span><span style="color: #0000FF;">,</span><span style="color: #000000;">6</span><span style="color: #0000FF;">,</span><span style="color: #000000;">7</span><span style="color: #0000FF;">,</span><span style="color: #000000;">8</span><span style="color: #0000FF;">,</span><span style="color: #000000;">9</span><span style="color: #0000FF;">,</span><span style="color: #000000;">20</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">300</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">4000</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">5555</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">6789</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">9394</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">7922</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">9999</span><span style="color: #0000FF;">})</span>
<!--</syntaxhighlight>-->
{{out}}
<pre>
Line 3,498 ⟶ 4,563:
| + / | +-+-+ | +-+ +-+ +-+-+ +-+-+
</pre>
 
=={{header|Plain English}}==
<langsyntaxhighlight lang="plainenglish">To run:
Start up.
Show some example Cistercian numbers.
Line 3,637 ⟶ 4,701:
To stroke nine:
Stroke 1.
Stroke 8.</langsyntaxhighlight>
{{out}}
https://commons.wikimedia.org/wiki/File:Cistercian_numerals.png
 
=={{header|Python}}==
I tried to create a three-line font from UTF8 characters taking three lines per Cistercian number.
<langsyntaxhighlight lang="python"># -*- coding: utf-8 -*-
"""
Some UTF-8 chars used:
Line 3,728 ⟶ 4,791:
for n in numbers[1:]:
lines = cjoin(lines, num_to_lines(n))
print('\n'.join(lines))</langsyntaxhighlight>
 
{{out}}
Line 3,764 ⟶ 4,827:
The pre tag may have to shift from one monospace font to a second that contains a character missing from the first. Those two individually monospaced fonts may have differing character widths between fonts (although consistent within individual monospaced fonts).<br>
Paste the output into a monospace code editor and the stems of each number might well align!
 
=={{header|Quackery}}==
 
<syntaxhighlight lang="Quackery"> [ $ "turtleduck.qky" loadfile ] now!
 
[ [ 50 dup * 2 * 1
10 vsqrt drop
join ] constant
do ] is diag ( --> n/d )
 
[ stack 1 ] is side ( --> s )
 
[ 0 side take
- side put ] is otherside ( --> )
 
[ 150 1 walk
-150 1 fly ] is trunk ( --> )
 
[ 50 1 fly ] is inset ( --> )
 
[ -50 1 fly ] is outset ( --> )
 
[ 150 1 fly
1 2 turn ] is otherend ( --> )
 
[ ] is zero ( --> )
 
[ -1 4 turn
50 side share *
dup 1 walk
negate 1 fly
1 4 turn ] is one ( --> )
 
[ inset one outset ] is two ( --> )
 
[ -1 side share *
8 turn
diag walk
diag -v fly
1 side share *
8 turn ] is three ( --> )
 
[ inset
-3 side share *
8 turn
diag walk
diag -v fly
3 side share *
8 turn
outset ] is four ( --> )
 
[ one four ] is five ( --> )
 
[ 1 side share *
4 turn outset
one
inset
-1 side share *
4 turn ] is six ( --> )
 
[ one six ] is seven ( --> )
 
[ two six ] is eight ( --> )
 
[ one two six ] is nine ( --> )
 
[ [ table
zero one two
three four five
six seven eight
nine ] do ] is thousands ( n --> )
 
[ otherend
thousands
otherend ] is units ( n --> )
 
[ otherside
units
otherside ] is tens ( n --> )
 
[ otherside
thousands
otherside ] is hundreds ( n --> )
 
[ inset
-1 4 turn
trunk
' [ units tens
hundreds
thousands ]
witheach
[ dip
[ 10 /mod ]
do ]
drop
1 4 turn
outset ] is cistercian ( n --> )
 
[ dup witheach
[ cistercian
3 times inset ]
size 3 * times
outset ] is task ( [ --> )
 
 
turtle 5 wide -600 1 fly
' [ 0 1 20 300 4000 5555 6789 1234 ] task</syntaxhighlight>
 
{{out}}
 
[[File:Quackery Cistercian numerals.png|frameless|center]]
 
=={{header|Raku}}==
Handles 0 through 9999 only. No error trapping. If you feed it an unsupported number it will truncate to maximum 4 digits.
 
<syntaxhighlight lang="raku" perl6line>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),
Line 3,817 ⟶ 4,991:
 
}
$out.say: q|</svg>|; # insert footer</langsyntaxhighlight>
{{out}}
[https://github.com/thundergnat/rc/blob/master/img/Cistercian-raku.svg See sample SVG image: (offsite link)]
[[File:Cistercian-raku.svg]]
 
=={{header|REXX}}==
Line 3,825 ⟶ 5,000:
 
Comprehensive error checking was also included.
<langsyntaxhighlight lang="rexx">/*REXX program displays a (non-negative 4-digit) integer in Cistercian (monk) numerals.*/
parse arg m /*obtain optional arguments from the CL*/
if m='' | m="," then m= 0 1 20 300 4000 5555 6789 9393 /*Not specified? Use defaults.*/
Line 3,908 ⟶ 5,083:
if q==2 then call p -5, 5, '└', -5, 9, "┌"
if q==3 then call p 5, 0, '┘', 5, 4, "┐"
if q==4 then call p -5, 0, '└', -5, 4, "┌"; return</langsyntaxhighlight>
{{out|output|text=&nbsp; when using the default inputs:}}
(Shown at three-quarter size.)
Line 3,929 ⟶ 5,104:
│ │ │ │/ / │ ─────┴───── │ └────┘ └────┘/
</pre>
 
=={{header|Ruby}}==
{{trans|Lua}}
<langsyntaxhighlight lang="ruby">def initN
n = Array.new(15){Array.new(11, ' ')}
for i in 1..15
Line 4,095 ⟶ 5,269:
end
printNumeral(n)
end</langsyntaxhighlight>
{{out}}
<pre>0:
Line 4,232 ⟶ 5,406:
x x x
xxxxxxxxxxx</pre>
 
=={{header|Rust}}==
{{trans|C}}
<syntaxhighlight lang="rust">use once_cell::sync::Lazy;
 
const GRID_SIZE: usize = 15;
static mut CANVAS: Lazy<Vec<[char; GRID_SIZE]>> = Lazy::new(|| vec![[' '; GRID_SIZE]; GRID_SIZE],);
 
/// initialize CANVAS
fn init_n() {
for i in 0..GRID_SIZE {
for j in 0..GRID_SIZE {
unsafe { CANVAS[i][j] = ' '; }
}
unsafe { CANVAS[i][5] = '#'; }
}
}
 
/// draw horizontal
fn horizontal(c1: usize, c2: usize, r: usize) {
for c in c1..=c2 {
unsafe { CANVAS[r][c] = '#'; }
}
}
 
/// draw vertical
fn vertical(r1: usize, r2: usize, c: usize) {
for r in r1..=r2 {
unsafe { CANVAS[r][c] = '#'; }
}
}
 
/// draw diagonal NE to SW
fn diag_d(c1 : usize, c2: usize, r: usize) {
for c in c1..=c2 {
unsafe { CANVAS[r + c - c1][c] = '#'; }
}
}
 
/// draw diagonal SE to NW
fn diag_u(c1: usize, c2: usize, r: usize) {
for c in c1..=c2 {
unsafe { CANVAS[r + c1 - c][c] = '#'; }
}
}
 
/// Mark the portions of the ones place.
fn draw_ones(v: i32) {
match v {
1 => horizontal(6, 10, 0),
2 => horizontal(6, 10, 4),
3 => diag_d(6, 10, 0),
4 => diag_u(6, 10, 4),
5 => { draw_ones(1); draw_ones(4); },
6 => vertical(0, 4, 10),
7 => { draw_ones(1); draw_ones(6); },
8 => { draw_ones(2); draw_ones(6); },
9 => { draw_ones(1); draw_ones(8); },
_ => {},
}
}
 
/// Mark the portions of the tens place.
fn draw_tens(v: i32) {
match v {
1 => horizontal(0, 4, 0),
2 => horizontal(0, 4, 4),
3 => diag_u(0, 4, 4),
4 => diag_d(0, 4, 0),
5 => { draw_tens(1); draw_tens(4); },
6 => vertical(0, 4, 0),
7 => { draw_tens(1); draw_tens(6); },
8 => { draw_tens(2); draw_tens(6); },
9 => { draw_tens(1); draw_tens(8); },
_ => {},
}
}
 
/// Mark the portions of the hundreds place.
fn draw_hundreds(hundreds: i32) {
match hundreds {
1 => horizontal(6, 10, 14),
2 => horizontal(6, 10, 10),
3 => diag_u(6, 10, 14),
4 => diag_d(6, 10, 10),
5 => { draw_hundreds(1); draw_hundreds(4) },
6 => vertical(10, 14, 10),
7 => { draw_hundreds(1); draw_hundreds(6); },
8 => { draw_hundreds(2); draw_hundreds(6); },
9 => { draw_hundreds(1); draw_hundreds(8); },
_ => {},
}
}
 
/// Mark the portions of the thousands place.
fn draw_thousands(thousands: i32) {
match thousands {
1 => horizontal(0, 4, 14),
2 => horizontal(0, 4, 10),
3 => diag_d(0, 4, 10),
4 => diag_u(0, 4, 14),
5 => { draw_thousands(1); draw_thousands(4); },
6 => vertical(10, 14, 0),
7 => { draw_thousands(1); draw_thousands(6); },
8 => { draw_thousands(2); draw_thousands(6); },
9 => { draw_thousands(1); draw_thousands(8); },
_ => {},
}
}
 
/// Mark the char matrix for the numeral drawing.
fn draw(mut v: i32) {
let thousands: i32 = v / 1000;
v %= 1000;
let hundreds: i32 = v / 100;
v %= 100;
let tens: i32 = v / 10;
let ones: i32 = v % 10;
if thousands > 0 {
draw_thousands(thousands);
}
if hundreds > 0 {
draw_hundreds(hundreds);
}
if tens > 0 {
draw_tens(tens);
}
if ones > 0 {
draw_ones(ones);
}
}
 
/// Test the drawings as outout to stdout.
fn test_output(n: i32) {
println!("{n}");
init_n();
draw(n);
unsafe {
for line in CANVAS.iter() {
for c in line.iter() {
print!("{}", *c);
}
println!();
}
}
println!("\n");
}
 
fn main() {
for n in [0, 1, 20, 300, 2022, 4000, 5555, 6789, 9999] {
test_output(n);
}
}
</syntaxhighlight>{{out}}
<pre>
0
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
 
 
1
######
#
#
#
#
#
#
#
#
#
#
#
#
#
#
 
 
20
#
#
#
#
######
#
#
#
#
#
#
#
#
#
#
 
 
300
#
#
#
#
#
#
#
#
#
#
# #
# #
# #
# #
##
 
 
2022
#
#
#
#
###########
#
#
#
#
#
######
#
#
#
#
 
 
4000
#
#
#
#
#
#
#
#
#
#
##
# #
# #
# #
# #
 
 
5555
###########
# # #
# # #
# # #
###
#
#
#
#
#
###
# # #
# # #
# # #
###########
 
 
6789
# ######
# # #
# # #
# # #
###########
#
#
#
#
#
# # #
# # #
# # #
# # #
# ######
 
 
9999
###########
# # #
# # #
# # #
###########
#
#
#
#
#
###########
# # #
# # #
# # #
###########
</pre>
 
=={{header|Wren}}==
{{libheader|Wren-fmt}}
This draws each Cistercian numeral on the terminal within a grid of 15 rows by 11 columns. The vertical line segment is drawn at column 5 (zero indexed) so there are 5 columns at either side.
<langsyntaxhighlight ecmascriptlang="wren">import "./fmt" for Fmt
 
var n
Line 4,357 ⟶ 5,847:
Fmt.mprint(n, 1, 0, "")
System.print()
}</langsyntaxhighlight>
 
{{out}}
2,442

edits