Cistercian numerals: Difference between revisions

m
→‎{{header|jq}}: <pre style="height:20lh;overflow:auto>
(Added AutoHotkey)
m (→‎{{header|jq}}: <pre style="height:20lh;overflow:auto>)
 
(26 intermediate revisions by 9 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.
<langsyntaxhighlight lang="68000devpac">;CONSTANTS
VFLIP equ %0001000000000000
HFLIP equ %0000100000000000
Line 312 ⟶ 310:
DC.B $80 ;23 DMA source address high (C=CMD) CCHHHHHH
VDPSettingsEnd:
even</langsyntaxhighlight>
 
{{out}}
[https://ibb.co/Fz11L4w Screenshot of emulator]
 
=={{header|Action!}}==
<langsyntaxhighlight Actionlang="action!">BYTE FUNC AtasciiToInternal(CHAR c)
BYTE c2
 
Line 424 ⟶ 421:
DO UNTIL CH#$FF OD
CH=$FF
RETURN</langsyntaxhighlight>
{{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}}==
<langsyntaxhighlight AutoHotkeylang="autohotkey">CistercianNumerals(num){
x := []
;UPPER LEFT 0 1 2 3 4 5 6 7 8 9
Line 466 ⟶ 550:
res := StrReplace(res, 1, "#")
return Trim(res, "`n")
}</langsyntaxhighlight>
Examples:<langsyntaxhighlight AutoHotkeylang="autohotkey">Gui, font, S24, Consolas
Gui, add, Text, vE1 w150 r12
Gui, show, x0 y0
Line 475 ⟶ 559:
MsgBox % num
}
return</langsyntaxhighlight>
{{out}}
<pre> 0 1 20 300 4000 5555 6789 2022
Line 493 ⟶ 577:
 
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f CISTERCIAN_NUMERALS.AWK [-v debug={0|1}] [-v xc=anychar] numbers 0-9999 ...
#
Line 567 ⟶ 651:
if (debug == 1) { printf("%s\n",header) }
}
</syntaxhighlight>
</lang>
{{out}}
<pre style="height: 60ex; overflow: scroll">
Line 710 ⟶ 794:
invalid
</pre>
 
=={{header|C}}==
{{trans|C#}}
<langsyntaxhighlight lang="c">#include <stdio.h>
 
#define GRID_SIZE 15
Line 959 ⟶ 1,042:
 
return 0;
}</langsyntaxhighlight>
{{out}}
<pre>0:
Line 1,103 ⟶ 1,186:
x x x
xxxxxxxxxxx</pre>
 
=={{header|C++}}==
{{trans|Go}}
<langsyntaxhighlight lang="cpp">#include <array>
#include <iostream>
 
Line 1,360 ⟶ 1,442:
 
return 0;
}</langsyntaxhighlight>
{{out}}
<pre>0:
Line 1,497 ⟶ 1,579:
x x x
xxxxxxxxxxx</pre>
 
=={{header|D}}==
{{trans|Java}}
<langsyntaxhighlight lang="d">import std.stdio;
 
class Cistercian {
Line 1,711 ⟶ 1,792:
writeln(c);
}
}</langsyntaxhighlight>
{{out}}
<pre>0:
Line 1,847 ⟶ 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,867 ⟶ 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,943 ⟶ 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,989 ⟶ 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 2,067 ⟶ 2,209:
=={{header|Fōrmulæ}}==
 
{{FormulaeEntry|page=https://formulae.org/?script=examples/Cistercian_numerals}}
Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text. Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation &mdash;i.e. XML, JSON&mdash; they are intended for storage and transfer purposes more than visualization and edition.
 
'''Solution'''
Programs in Fōrmulæ are created/edited online in its [https://formulae.org website], However they run on execution servers. By default remote servers are used, but they are limited in memory and processing power, since they are intended for demonstration and casual use. A local server can be downloaded and installed, it has no limitations (it runs in your own computer). Because of that, example programs can be fully visualized and edited, but some of them will not run if they require a moderate or heavy computation/memory resources, and no local server is being used.
 
We can take advantage of the coordinate transformations.
In '''[https://formulae.org/?example=Cistercian_numerals this]''' page you can see the program(s) related to this task and their results.
 
'''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 2,197 ⟶ 2,509:
printNumeral()
}
}</langsyntaxhighlight>
 
{{out}}
Line 2,203 ⟶ 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 2,212 ⟶ 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 2,394 ⟶ 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,607 ⟶ 2,917:
}
}
}</langsyntaxhighlight>
{{out}}
<pre>0:
Line 2,744 ⟶ 3,054:
x x x
xxxxxxxxxxx </pre>
 
=={{header|JavaScript}}==
Using a canvas.
<syntaxhighlight lang="javascript">
<lang javaScript>
// html
document.write(`
Line 2,850 ⟶ 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,913 ⟶ 3,453:
 
mooncipher()
</syntaxhighlight>
</lang>
 
=={{header|Kotlin}}==
{{trans|C++}}
<langsyntaxhighlight lang="scala">import java.io.StringWriter
 
class Cistercian() {
Line 3,140 ⟶ 3,680:
}
 
}</langsyntaxhighlight>
{{out}}
<pre>0:
Line 3,277 ⟶ 3,817:
x x x
xxxxxxxxxxx </pre>
 
=={{header|Lua}}==
{{trans|Go}}
<langsyntaxhighlight lang="lua">function initN()
local n = {}
for i=1,15 do
Line 3,399 ⟶ 3,938:
end
 
main()</langsyntaxhighlight>
{{out}}
<pre>0:
Line 3,536 ⟶ 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,578 ⟶ 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,742 ⟶ 4,279:
for number in [0, 1, 20, 300, 4000, 5555, 6789, 9999]:
echo number, ':'
echo cistercian(number)</langsyntaxhighlight>
 
{{out}}
Line 3,881 ⟶ 4,418:
xxxxxxxxxxx
</pre>
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl">#!/usr/bin/perl
 
use strict; # https://rosettacode.org/wiki/Cistercian_numerals
Line 3,927 ⟶ 4,463:
}
return $_;
}</langsyntaxhighlight>
{{out}}
<pre>
Line 3,944 ⟶ 4,480:
# # # # # # ######### # ##### #######
</pre>
 
=={{header|Phix}}==
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #000080;font-style:italic;">--
-- Define each digit as {up-down multiplier, left-right multiplier, char},
Line 4,007 ⟶ 4,542:
<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>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 4,028 ⟶ 4,563:
| + / | +-+-+ | +-+ +-+ +-+-+ +-+-+
</pre>
 
=={{header|Plain English}}==
<langsyntaxhighlight lang="plainenglish">To run:
Start up.
Show some example Cistercian numbers.
Line 4,167 ⟶ 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 4,258 ⟶ 4,791:
for n in numbers[1:]:
lines = cjoin(lines, num_to_lines(n))
print('\n'.join(lines))</langsyntaxhighlight>
 
{{out}}
Line 4,294 ⟶ 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 4,347 ⟶ 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 4,355 ⟶ 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 4,438 ⟶ 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 4,459 ⟶ 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,625 ⟶ 5,269:
end
printNumeral(n)
end</langsyntaxhighlight>
{{out}}
<pre>0:
Line 4,762 ⟶ 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,887 ⟶ 5,847:
Fmt.mprint(n, 1, 0, "")
System.print()
}</langsyntaxhighlight>
 
{{out}}
2,442

edits