Cistercian numerals: Difference between revisions

Content added Content deleted
(Added AutoHotkey)
m (syntax highlighting fixup automation)
Line 38: Line 38:
=={{header|68000 Assembly}}==
=={{header|68000 Assembly}}==
This Sega Genesis cartridge can be compiled with VASM and run in the Fusion emulator.
This Sega Genesis cartridge can be compiled with VASM and run in the Fusion emulator.
<lang 68000devpac>;CONSTANTS
<syntaxhighlight lang=68000devpac>;CONSTANTS
VFLIP equ %0001000000000000
VFLIP equ %0001000000000000
HFLIP equ %0000100000000000
HFLIP equ %0000100000000000
Line 312: Line 312:
DC.B $80 ;23 DMA source address high (C=CMD) CCHHHHHH
DC.B $80 ;23 DMA source address high (C=CMD) CCHHHHHH
VDPSettingsEnd:
VDPSettingsEnd:
even</lang>
even</syntaxhighlight>


{{out}}
{{out}}
Line 318: Line 318:


=={{header|Action!}}==
=={{header|Action!}}==
<lang Action!>BYTE FUNC AtasciiToInternal(CHAR c)
<syntaxhighlight lang=Action!>BYTE FUNC AtasciiToInternal(CHAR c)
BYTE c2
BYTE c2


Line 424: Line 424:
DO UNTIL CH#$FF OD
DO UNTIL CH#$FF OD
CH=$FF
CH=$FF
RETURN</lang>
RETURN</syntaxhighlight>
{{out}}
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Cistercian_numerals.png Screenshot from Atari 8-bit computer]
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Cistercian_numerals.png Screenshot from Atari 8-bit computer]


=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==
<lang AutoHotkey>CistercianNumerals(num){
<syntaxhighlight lang=AutoHotkey>CistercianNumerals(num){
x := []
x := []
;UPPER LEFT 0 1 2 3 4 5 6 7 8 9
;UPPER LEFT 0 1 2 3 4 5 6 7 8 9
Line 466: Line 466:
res := StrReplace(res, 1, "#")
res := StrReplace(res, 1, "#")
return Trim(res, "`n")
return Trim(res, "`n")
}</lang>
}</syntaxhighlight>
Examples:<lang AutoHotkey>Gui, font, S24, Consolas
Examples:<syntaxhighlight lang=AutoHotkey>Gui, font, S24, Consolas
Gui, add, Text, vE1 w150 r12
Gui, add, Text, vE1 w150 r12
Gui, show, x0 y0
Gui, show, x0 y0
Line 475: Line 475:
MsgBox % num
MsgBox % num
}
}
return</lang>
return</syntaxhighlight>
{{out}}
{{out}}
<pre> 0 1 20 300 4000 5555 6789 2022
<pre> 0 1 20 300 4000 5555 6789 2022
Line 493: Line 493:


=={{header|AWK}}==
=={{header|AWK}}==
<lang AWK>
<syntaxhighlight lang=AWK>
# syntax: GAWK -f CISTERCIAN_NUMERALS.AWK [-v debug={0|1}] [-v xc=anychar] numbers 0-9999 ...
# syntax: GAWK -f CISTERCIAN_NUMERALS.AWK [-v debug={0|1}] [-v xc=anychar] numbers 0-9999 ...
#
#
Line 567: Line 567:
if (debug == 1) { printf("%s\n",header) }
if (debug == 1) { printf("%s\n",header) }
}
}
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre style="height: 60ex; overflow: scroll">
<pre style="height: 60ex; overflow: scroll">
Line 713: Line 713:
=={{header|C}}==
=={{header|C}}==
{{trans|C#}}
{{trans|C#}}
<lang c>#include <stdio.h>
<syntaxhighlight lang=c>#include <stdio.h>


#define GRID_SIZE 15
#define GRID_SIZE 15
Line 959: Line 959:


return 0;
return 0;
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>0:
<pre>0:
Line 1,106: Line 1,106:
=={{header|C++}}==
=={{header|C++}}==
{{trans|Go}}
{{trans|Go}}
<lang cpp>#include <array>
<syntaxhighlight lang=cpp>#include <array>
#include <iostream>
#include <iostream>


Line 1,360: Line 1,360:


return 0;
return 0;
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>0:
<pre>0:
Line 1,500: Line 1,500:
=={{header|D}}==
=={{header|D}}==
{{trans|Java}}
{{trans|Java}}
<lang d>import std.stdio;
<syntaxhighlight lang=d>import std.stdio;


class Cistercian {
class Cistercian {
Line 1,711: Line 1,711:
writeln(c);
writeln(c);
}
}
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>0:
<pre>0:
Line 1,849: Line 1,849:


=={{header|F_Sharp|F#}}==
=={{header|F_Sharp|F#}}==
<lang fsharp>
<syntaxhighlight lang=fsharp>
// Cistercian numerals. Nigel Galloway: February 2nd., 2021
// Cistercian numerals. Nigel Galloway: February 2nd., 2021
let N=[|[[|' ';' ';' '|];[|' ';' ';' '|];[|' ';' ';' '|]];
let N=[|[[|' ';' ';' '|];[|' ';' ';' '|];[|' ';' ';' '|]];
Line 1,867: Line 1,867:


[(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)
[(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}}
{{out}}
<pre>
<pre>
Line 1,943: Line 1,943:
=={{header|Factor}}==
=={{header|Factor}}==
{{works with|Factor|0.99 2020-08-14}}
{{works with|Factor|0.99 2020-08-14}}
<lang factor>USING: combinators continuations formatting grouping io kernel
<syntaxhighlight lang=factor>USING: combinators continuations formatting grouping io kernel
literals math.order math.text.utils multiline sequences
literals math.order math.text.utils multiline sequences
splitting ;
splitting ;
Line 1,989: Line 1,989:
with-datastack [ ] [ overwrite ] map-reduce [ print ] each ;
with-datastack [ ] [ overwrite ] map-reduce [ print ] each ;


{ 0 1 20 300 4000 5555 6789 8015 } [ .cistercian nl ] each</lang>
{ 0 1 20 300 4000 5555 6789 8015 } [ .cistercian nl ] each</syntaxhighlight>
{{out}}
{{out}}
<pre style="height: 60ex; overflow: scroll">
<pre style="height: 60ex; overflow: scroll">
Line 2,075: Line 2,075:
=={{header|Go}}==
=={{header|Go}}==
{{trans|Wren}}
{{trans|Wren}}
<lang go>package main
<syntaxhighlight lang=go>package main


import "fmt"
import "fmt"
Line 2,197: Line 2,197:
printNumeral()
printNumeral()
}
}
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 2,212: Line 2,212:
</pre>
</pre>
The <tt>rc</tt> verb writes <tt>RC=. 0 1 20 300 666 4000 5555 6789</tt>
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. http://rosettacode.org/wiki/Cistercian_numerals
NB. converted from
NB. converted from
Line 2,394: Line 2,394:
'open browser to {}{}{}' format~ (pwd'') ; PATHJSEP_j_ ; y
'open browser to {}{}{}' format~ (pwd'') ; PATHJSEP_j_ ; y
)
)
</syntaxhighlight>
</lang>


=={{header|Java}}==
=={{header|Java}}==
{{trans|Kotlin}}
{{trans|Kotlin}}
<lang java>import java.util.Arrays;
<syntaxhighlight lang=java>import java.util.Arrays;
import java.util.List;
import java.util.List;


Line 2,607: Line 2,607:
}
}
}
}
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>0:
<pre>0:
Line 2,747: Line 2,747:
=={{header|JavaScript}}==
=={{header|JavaScript}}==
Using a canvas.
Using a canvas.
<lang javaScript>
<syntaxhighlight lang=javaScript>
// html
// html
document.write(`
document.write(`
Line 2,850: Line 2,850:
}
}
}
}
</syntaxhighlight>
</lang>
{{out}}<pre>
{{out}}<pre>
https://jsfiddle.net/43tsmn9z</pre>
https://jsfiddle.net/43tsmn9z</pre>
Line 2,856: Line 2,856:
=={{header|Julia}}==
=={{header|Julia}}==
Gtk graphic version.
Gtk graphic version.
<lang julia>using Gtk, Cairo
<syntaxhighlight lang=julia>using Gtk, Cairo


const can = GtkCanvas(800, 100)
const can = GtkCanvas(800, 100)
Line 2,913: Line 2,913:


mooncipher()
mooncipher()
</syntaxhighlight>
</lang>


=={{header|Kotlin}}==
=={{header|Kotlin}}==
{{trans|C++}}
{{trans|C++}}
<lang scala>import java.io.StringWriter
<syntaxhighlight lang=scala>import java.io.StringWriter


class Cistercian() {
class Cistercian() {
Line 3,140: Line 3,140:
}
}


}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>0:
<pre>0:
Line 3,280: Line 3,280:
=={{header|Lua}}==
=={{header|Lua}}==
{{trans|Go}}
{{trans|Go}}
<lang lua>function initN()
<syntaxhighlight lang=lua>function initN()
local n = {}
local n = {}
for i=1,15 do
for i=1,15 do
Line 3,399: Line 3,399:
end
end


main()</lang>
main()</syntaxhighlight>
{{out}}
{{out}}
<pre>0:
<pre>0:
Line 3,538: Line 3,538:


=={{header|Mathematica}}/{{header|Wolfram Language}}==
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<lang Mathematica>ClearAll[CistercianNumberEncodeHelper, CistercianNumberEncode]
<syntaxhighlight lang=Mathematica>ClearAll[CistercianNumberEncodeHelper, CistercianNumberEncode]
\[Delta] = 0.25;
\[Delta] = 0.25;
CistercianNumberEncodeHelper[0] := {}
CistercianNumberEncodeHelper[0] := {}
Line 3,578: Line 3,578:
CistercianNumberEncode[5555]
CistercianNumberEncode[5555]
CistercianNumberEncode[6789]
CistercianNumberEncode[6789]
CistercianNumberEncode[1337]</lang>
CistercianNumberEncode[1337]</syntaxhighlight>
{{out}}
{{out}}
A set of Graphics is shown for each of the numerals.
A set of Graphics is shown for each of the numerals.
Line 3,584: Line 3,584:
=={{header|Nim}}==
=={{header|Nim}}==
{{trans|Kotlin}}
{{trans|Kotlin}}
<lang Nim>const Size = 15
<syntaxhighlight lang=Nim>const Size = 15


type Canvas = array[Size, array[Size, char]]
type Canvas = array[Size, array[Size, char]]
Line 3,742: Line 3,742:
for number in [0, 1, 20, 300, 4000, 5555, 6789, 9999]:
for number in [0, 1, 20, 300, 4000, 5555, 6789, 9999]:
echo number, ':'
echo number, ':'
echo cistercian(number)</lang>
echo cistercian(number)</syntaxhighlight>


{{out}}
{{out}}
Line 3,883: Line 3,883:


=={{header|Perl}}==
=={{header|Perl}}==
<lang perl>#!/usr/bin/perl
<syntaxhighlight lang=perl>#!/usr/bin/perl


use strict; # https://rosettacode.org/wiki/Cistercian_numerals
use strict; # https://rosettacode.org/wiki/Cistercian_numerals
Line 3,927: Line 3,927:
}
}
return $_;
return $_;
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 3,946: Line 3,946:


=={{header|Phix}}==
=={{header|Phix}}==
<!--<lang Phix>(phixonline)-->
<!--<syntaxhighlight lang=Phix>(phixonline)-->
<span style="color: #000080;font-style:italic;">--
<span style="color: #000080;font-style:italic;">--
-- Define each digit as {up-down multiplier, left-right multiplier, char},
-- Define each digit as {up-down multiplier, left-right multiplier, char},
Line 4,007: Line 4,007:
<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>
<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>
<!--</lang>-->
<!--</syntaxhighlight>-->
{{out}}
{{out}}
<pre>
<pre>
Line 4,030: Line 4,030:


=={{header|Plain English}}==
=={{header|Plain English}}==
<lang plainenglish>To run:
<syntaxhighlight lang=plainenglish>To run:
Start up.
Start up.
Show some example Cistercian numbers.
Show some example Cistercian numbers.
Line 4,167: Line 4,167:
To stroke nine:
To stroke nine:
Stroke 1.
Stroke 1.
Stroke 8.</lang>
Stroke 8.</syntaxhighlight>
{{out}}
{{out}}
https://commons.wikimedia.org/wiki/File:Cistercian_numerals.png
https://commons.wikimedia.org/wiki/File:Cistercian_numerals.png
Line 4,173: Line 4,173:
=={{header|Python}}==
=={{header|Python}}==
I tried to create a three-line font from UTF8 characters taking three lines per Cistercian number.
I tried to create a three-line font from UTF8 characters taking three lines per Cistercian number.
<lang python># -*- coding: utf-8 -*-
<syntaxhighlight lang=python># -*- coding: utf-8 -*-
"""
"""
Some UTF-8 chars used:
Some UTF-8 chars used:
Line 4,258: Line 4,258:
for n in numbers[1:]:
for n in numbers[1:]:
lines = cjoin(lines, num_to_lines(n))
lines = cjoin(lines, num_to_lines(n))
print('\n'.join(lines))</lang>
print('\n'.join(lines))</syntaxhighlight>


{{out}}
{{out}}
Line 4,298: Line 4,298:
Handles 0 through 9999 only. No error trapping. If you feed it an unsupported number it will truncate to maximum 4 digits.
Handles 0 through 9999 only. No error trapping. If you feed it an unsupported number it will truncate to maximum 4 digits.


<lang perl6>my @line-segments = (0, 0, 0, 100),
<syntaxhighlight lang=raku line>my @line-segments = (0, 0, 0, 100),
(0, 0, 35, 0), (0, 35, 35, 35), (0, 0, 35, 35), (0, 35, 35, 0), ( 35, 0, 35, 35),
(0, 0, 35, 0), (0, 35, 35, 35), (0, 0, 35, 35), (0, 35, 35, 0), ( 35, 0, 35, 35),
(0, 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: Line 4,347:


}
}
$out.say: q|</svg>|; # insert footer</lang>
$out.say: q|</svg>|; # insert footer</syntaxhighlight>
[https://github.com/thundergnat/rc/blob/master/img/Cistercian-raku.svg See sample SVG image: (offsite link)]
[https://github.com/thundergnat/rc/blob/master/img/Cistercian-raku.svg See sample SVG image: (offsite link)]


Line 4,355: Line 4,355:


Comprehensive error checking was also included.
Comprehensive error checking was also included.
<lang rexx>/*REXX program displays a (non-negative 4-digit) integer in Cistercian (monk) numerals.*/
<syntaxhighlight lang=rexx>/*REXX program displays a (non-negative 4-digit) integer in Cistercian (monk) numerals.*/
parse arg m /*obtain optional arguments from the CL*/
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.*/
if m='' | m="," then m= 0 1 20 300 4000 5555 6789 9393 /*Not specified? Use defaults.*/
Line 4,438: Line 4,438:
if q==2 then call p -5, 5, '└', -5, 9, "┌"
if q==2 then call p -5, 5, '└', -5, 9, "┌"
if q==3 then call p 5, 0, '┘', 5, 4, "┐"
if q==3 then call p 5, 0, '┘', 5, 4, "┐"
if q==4 then call p -5, 0, '└', -5, 4, "┌"; return</lang>
if q==4 then call p -5, 0, '└', -5, 4, "┌"; return</syntaxhighlight>
{{out|output|text=&nbsp; when using the default inputs:}}
{{out|output|text=&nbsp; when using the default inputs:}}
(Shown at three-quarter size.)
(Shown at three-quarter size.)
Line 4,462: Line 4,462:
=={{header|Ruby}}==
=={{header|Ruby}}==
{{trans|Lua}}
{{trans|Lua}}
<lang ruby>def initN
<syntaxhighlight lang=ruby>def initN
n = Array.new(15){Array.new(11, ' ')}
n = Array.new(15){Array.new(11, ' ')}
for i in 1..15
for i in 1..15
Line 4,625: Line 4,625:
end
end
printNumeral(n)
printNumeral(n)
end</lang>
end</syntaxhighlight>
{{out}}
{{out}}
<pre>0:
<pre>0:
Line 4,766: Line 4,766:
{{libheader|Wren-fmt}}
{{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.
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.
<lang ecmascript>import "/fmt" for Fmt
<syntaxhighlight lang=ecmascript>import "/fmt" for Fmt


var n
var n
Line 4,887: Line 4,887:
Fmt.mprint(n, 1, 0, "")
Fmt.mprint(n, 1, 0, "")
System.print()
System.print()
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}