How to resolve the algorithm Cistercian numerals step by step in the Action! programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Cistercian numerals step by step in the Action! programming language

Table of Contents

Problem Statement

Cistercian numerals were used across Europe by Cistercian monks during the Late Medieval Period as an alternative to Roman numerals. They were used to represent base 10 integers from 0 to 9999. All Cistercian numerals begin with a vertical line segment, which by itself represents the number 0. Then, glyphs representing the digits 1 through 9 are optionally added to the four quadrants surrounding the vertical line segment. These glyphs are drawn with vertical and horizontal symmetry about the initial line segment. Each quadrant corresponds to a digit place in the number: Please consult the following image for examples of Cistercian numerals showing each glyph: [1] Due to the inability to upload images to Rosetta Code as of this task's creation, showing output here on this page is not required. However, it is welcomed — especially for text output.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Cistercian numerals step by step in the Action! programming language

Source code in the action! programming language

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

  

You may also check:How to resolve the algorithm Greatest element of a list step by step in the Slate programming language
You may also check:How to resolve the algorithm User input/Text step by step in the Nemerle programming language
You may also check:How to resolve the algorithm Playfair cipher step by step in the Go programming language
You may also check:How to resolve the algorithm Compiler/AST interpreter step by step in the COBOL programming language
You may also check:How to resolve the algorithm Multiplication tables step by step in the Phix programming language