Cistercian numerals: Difference between revisions

Added solution for Action!
(Added Fōrmulæ solution)
(Added solution for Action!)
Line 35:
:* '''[https://www.dcode.fr/cistercian-numbers dcode.fr - Online Cistercian numeral converter]'''
 
 
=={{header|Action!}}==
<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</lang>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Cistercian_numerals.png Screenshot from Atari 8-bit computer]
 
=={{header|AWK}}==
Anonymous user