Mayan numerals

From Rosetta Code
Revision as of 07:12, 17 January 2019 by Hout (talk | contribs) (→‎{{header|JavaScript}}: Switched off wikiTable default styling)
Mayan numerals is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Task

Present numbers using the Mayan numbering system   (displaying the Mayan numerals in a cartouche).


Mayan numbers

Normally, Mayan numbers are written vertically   (top─to─bottom)   with the most significant numeral at the top   (in the sense that decimal numbers are written left─to─right with the most significant digit at the left).   This task will be using a left─to─right (horizontal) format,   mostly for familiarity and readability,   and to conserve screen space (when showing the output) on this task page.


Mayan numerals

Mayan numerals   (a base─20 "digit" or glyph)   are written in two orientations,   this task will be using the "vertical" format   (as displayed below).   Using the vertical format makes it much easier to draw/construct the Mayan numerals (glyphs) with simple dots (.) and hyphen (-);     (however, round bullets () and long dashes () make a better presentation on Rosetta Code).


Furthermore, each Mayan numeral   (for this task)   is to be displayed as a cartouche   (enclosed in a box)   to make it easier to parse (read);   the box may be drawn with any suitable (ASCII or Unicode) characters that are presentable/visible in all web browsers.


Mayan numerals added to Unicode

Mayan numerals (glyphs) were added to the Unicode Standard in June of 2018   (this corresponds with version 11.0).   But since most web browsers don't support them at this time,   this Rosetta Code task will be constructing the glyphs with "simple" characters and/or ASCII art.


The "zero" glyph

The Mayan numbering system has the concept of   zero,   and should be shown by a glyph that represents an upside─down (sea) shell,   or an egg.   The Greek letter theta   (Θ)   can be used   (which more─or─less, looks like an egg).   A   commercial at   symbol   (@)   could make a poor substitute.


Mayan glyphs (constructed)

The Mayan numbering system is a   [vigesimal (base 20)]   positional numeral system.


The Mayan numerals   (and some random numbers)   shown in the   vertical   format would be shown as
      ╔════╗                      ╔════╗                            ╔════╦════╗
      ║    ║                      ║    ║                            ║    ║    ║
      ║    ║                      ║ ∙  ║                            ║    ║    ║
 1──► ║    ║                11──► ║────║                      21──► ║    ║    ║
      ║ ∙  ║                      ║────║                            ║ ∙  ║ ∙  ║
      ╚════╝                      ╚════╝                            ╚════╩════╝
      ╔════╗                      ╔════╗                            ╔════╦════╗
      ║    ║                      ║    ║                            ║    ║    ║
      ║    ║                      ║ ∙∙ ║                            ║    ║    ║
 2──► ║    ║                12──► ║────║                      22──► ║    ║    ║
      ║ ∙∙ ║                      ║────║                            ║ ∙  ║ ∙∙ ║
      ╚════╝                      ╚════╝                            ╚════╩════╝
      ╔════╗                      ╔════╗                            ╔════╦════╗
      ║    ║                      ║    ║                            ║    ║    ║
      ║    ║                      ║∙∙∙ ║                            ║    ║    ║
 3──► ║    ║                13──► ║────║                      40──► ║    ║    ║
      ║∙∙∙ ║                      ║────║                            ║ ∙∙ ║ Θ  ║
      ╚════╝                      ╚════╝                            ╚════╩════╝
      ╔════╗                      ╔════╗                            ╔════╦════╗
      ║    ║                      ║    ║                            ║    ║    ║
      ║    ║                      ║∙∙∙∙║                            ║    ║    ║
 4──► ║    ║                14──► ║────║                      80──► ║    ║    ║
      ║∙∙∙∙║                      ║────║                            ║∙∙∙∙║ Θ  ║
      ╚════╝                      ╚════╝                            ╚════╩════╝
      ╔════╗                      ╔════╗                            ╔════╦════╗
      ║    ║                      ║    ║                            ║    ║    ║
      ║    ║                      ║────║                            ║    ║    ║
 5──► ║    ║                15──► ║────║                      90──► ║    ║────║
      ║────║                      ║────║                            ║∙∙∙∙║────║
      ╚════╝                      ╚════╝                            ╚════╩════╝
      ╔════╗                      ╔════╗                            ╔════╦════╗
      ║    ║                      ║ ∙  ║                            ║    ║    ║
      ║    ║                      ║────║                            ║    ║    ║
 6──► ║ ∙  ║                16──► ║────║                     100──► ║    ║    ║
      ║────║                      ║────║                            ║────║ Θ  ║
      ╚════╝                      ╚════╝                            ╚════╩════╝
      ╔════╗                      ╔════╗                            ╔════╦════╗
      ║    ║                      ║ ∙∙ ║                            ║    ║    ║
      ║    ║                      ║────║                            ║    ║    ║
 7──► ║ ∙∙ ║                17──► ║────║                     200──► ║────║    ║
      ║────║                      ║────║                            ║────║ Θ  ║
      ╚════╝                      ╚════╝                            ╚════╩════╝
      ╔════╗                      ╔════╗                            ╔════╦════╗
      ║    ║                      ║∙∙∙ ║                            ║    ║    ║
      ║    ║                      ║────║                     300──► ║────║    ║
 8──► ║∙∙∙ ║                18──► ║────║                            ║────║    ║
      ║────║                      ║────║                            ║────║ Θ  ║
      ╚════╝                      ╚════╝                            ╚════╩════╝
      ╔════╗                      ╔════╗                            ╔════╦════╦════╗
      ║    ║                      ║∙∙∙∙║                            ║    ║    ║    ║
      ║    ║                      ║────║                     400──► ║    ║    ║    ║
 9──► ║∙∙∙∙║                19──► ║────║                            ║    ║    ║    ║
      ║────║                      ║────║                            ║ ∙  ║ Θ  ║ Θ  ║
      ╚════╝                      ╚════╝                            ╚════╩════╩════╝
      ╔════╗                      ╔════╦════╗                       ╔════╦════╦════╦════╗
      ║    ║                      ║    ║    ║                       ║    ║    ║    ║    ║
      ║    ║                      ║    ║    ║                       ║    ║    ║    ║    ║
10──► ║────║                20──► ║    ║    ║             16,000──► ║    ║    ║    ║    ║
      ║────║                      ║ ∙  ║ Θ  ║                       ║ ∙∙ ║ Θ  ║ Θ  ║ Θ  ║
      ╚════╝                      ╚════╩════╝                       ╚════╩════╩════╩════╝


Note that the Mayan numeral   13   in   horizontal   format would be shown as:

                                  ╔════╗
                                  ║  ││║
                                  ║ ∙││║
                            13──► ║ ∙││║        ◄─── this glyph form won't be used in this Rosetta Code task.
                                  ║ ∙││║
                                  ╚════╝


Other forms of cartouches (boxes) can be used for this task.


Task requirements
  •   convert the following decimal numbers to Mayan numbers:
  •       4,005
  •       8,017
  •   326,205
  •   886,205
  •   show a   unique   interesting/pretty/unusual/intriguing/odd/amusing/weird   Mayan number
  •   show all output here


Related tasks


See also




Go

<lang go>package main

import (

   "fmt"
   "strconv"

)

const (

   ul = "╔"
   uc = "╦"
   ur = "╗"
   ll = "╚"
   lc = "╩"
   lr = "╝"
   hb = "═"
   vb = "║"

)

var mayan = [5]string{

   "    ",
   " ∙  ",
   " ∙∙ ",
   "∙∙∙ ",
   "∙∙∙∙",

}

const (

   m0 = " Θ  "
   m5 = "────"

)

func dec2vig(n uint64) []uint64 {

   vig := strconv.FormatUint(n, 20)
   res := make([]uint64, len(vig))
   for i, d := range vig {
       res[i], _ = strconv.ParseUint(string(d), 20, 64)
   }
   return res

}

func vig2quin(n uint64) [4]string {

   if n >= 20 {
       panic("Cant't convert a number >= 20")
   }
   res := [4]string{mayan[0], mayan[0], mayan[0], mayan[0]}
   if n == 0 {
       res[3] = m0
       return res
   }
   fives := n / 5
   rem := n % 5
   res[3-fives] = mayan[rem]
   for i := 3; i > 3-int(fives); i-- {
       res[i] = m5
   }
   return res

}

func draw(mayans [][4]string) {

   lm := len(mayans)
   fmt.Print(ul)
   for i := 0; i < lm; i++ {
       for j := 0; j < 4; j++ {
           fmt.Print(hb)
       }
       if i < lm-1 {
           fmt.Print(uc)
       } else {
           fmt.Println(ur)
       }
   }
   for i := 1; i < 5; i++ {
       fmt.Print(vb)
       for j := 0; j < lm; j++ {
           fmt.Print(mayans[j][i-1])
           fmt.Print(vb)
       }
       fmt.Println()
   }
   fmt.Print(ll)
   for i := 0; i < lm; i++ {
       for j := 0; j < 4; j++ {
           fmt.Print(hb)
       }
       if i < lm-1 {
           fmt.Print(lc)
       } else {
           fmt.Println(lr)
       }
   }

}

func main() {

   numbers := []uint64{4005, 8017, 326205, 886205, 1081439556}
   for _, n := range numbers {
       fmt.Printf("Converting %d to Mayan:\n", n)
       vigs := dec2vig(n)
       lv := len(vigs)
       mayans := make([][4]string, lv)
       for i, vig := range vigs {
           mayans[i] = vig2quin(vig)
       }
       draw(mayans)
       fmt.Println()
   }

}</lang>

Output:
Converting 4005 to Mayan:
╔════╦════╦════╗
║    ║    ║    ║
║    ║    ║    ║
║────║    ║    ║
║────║ Θ  ║────║
╚════╩════╩════╝

Converting 8017 to Mayan:
╔════╦════╦════╦════╗
║    ║    ║    ║ ∙∙ ║
║    ║    ║    ║────║
║    ║    ║    ║────║
║ ∙  ║ Θ  ║ Θ  ║────║
╚════╩════╩════╩════╝

Converting 326205 to Mayan:
╔════╦════╦════╦════╦════╗
║    ║    ║    ║    ║    ║
║    ║    ║────║    ║    ║
║    ║    ║────║────║    ║
║ ∙∙ ║ Θ  ║────║────║────║
╚════╩════╩════╩════╩════╝

Converting 886205 to Mayan:
╔════╦════╦════╦════╦════╗
║    ║    ║    ║    ║    ║
║    ║    ║────║    ║    ║
║    ║────║────║────║    ║
║────║────║────║────║────║
╚════╩════╩════╩════╩════╝

Converting 1081439556 to Mayan:
╔════╦════╦════╦════╦════╦════╦════╗
║ ∙  ║ ∙∙ ║∙∙∙ ║∙∙∙∙║∙∙∙ ║ ∙∙ ║ ∙  ║
║────║────║────║────║────║────║────║
║────║────║────║────║────║────║────║
║────║────║────║────║────║────║────║
╚════╩════╩════╩════╩════╩════╩════╝

Haskell

<lang haskell>import Data.List (intercalate, transpose) import Control.Applicative (liftA2) import Control.Monad (join)

-- MAIN --------------------------------------------------- main :: IO () main =

 (putStrLn . unlines) $
 mayanFramed <$> [4005, 8017, 326205, 886205, 1081439556, 1000000, 1000000000]

-- MAYAN NUMBERS ------------------------------------------

mayanFramed :: Int -> String mayanFramed =

 ("Mayan " ++) . liftA2 (++) show ((":\n\n" ++) . wikiTable . mayanGlyph)

mayanGlyph

 :: Integral a
 => a -> String

mayanGlyph =

 filter (any (not . null)) .
 transpose . leftPadded . flip (showIntAtBaseS 20 mayanDigit) []

mayanDigit :: Int -> [String] mayanDigit n

 | 0 /= n =
   replicate (rem n 5) '\9679' : join (replicate (quot n 5) ["\9472\9472"])
 | otherwise = ["\952"]

-- NUMERIC BASES ------------------------------------------

-- Based on the Prelude showIntAtBase but uses an (Int -> [String]) -- (rather than Int -> Char) function as its second argument. -- -- Shows a /non-negative/ 'Integral' number using the base specified by the -- first argument, and the **String** representation specified by the second. showIntAtBaseS

 :: Integral a
 => a -> (Int -> [String]) -> a -> String -> String

showIntAtBaseS base toStr n0 r0 =

 let go (n, d) r =
       seq s $
       case n of
         0 -> r_
         _ -> go (quotRem n base) r_
       where
         s = toStr (fromIntegral d)
         r_ = s : r
 in go (quotRem n0 base) r0

-- DISPLAY ------------------------------------------------

wikiTable :: String -> String wikiTable =

 join .
 ("{| class=\"wikitable\" style=\"text-align:center;" :) .
 ("border:2px solid silver\"\n|-\n" :) .
 return .
 (++ "\n|}") .
 intercalate "\n|-\n" . fmap (('|' :) . (' ' :) . intercalate " || ")

leftPadded :: String -> String leftPadded xs =

 let w = maximum (length <$> xs)
 in ((++) =<< flip replicate [] . (-) w . length) <$> xs</lang>
Output:

Mayan 4005:

──
── θ ──

Mayan 8017:

●●
──
──
θ θ ──

Mayan 326205:

──
── ──
●● θ ── ── ──

Mayan 886205:

──
── ── ──
── ── ── ── ──

Mayan 1081439556:

●● ●●● ●●●● ●●● ●●
── ── ── ── ── ── ──
── ── ── ── ── ── ──
── ── ── ── ── ── ──

Mayan 1000000:

── ── θ θ θ

Mayan 1000000000:

── ●●
── ── ──
── ── ── θ θ θ θ

JavaScript

<lang JavaScript>(() => {

   'use strict';
   const main = () =>
       unlines(
           map(mayanFramed,
               [4005, 8017, 326205, 886205, 1081439556, 1000000, 1000000000]
           )
       );
   // MAYAN NUMBERS --------------------------------------
   // mayanFramed :: Int -> String
   const mayanFramed = n =>
       'Mayan ' + n.toString() + ':\n\n' +
       wikiTable({
           style: 'text-align:center; border:2px solid silver;',
           colwidth: '3em'
       })(
           mayanGlyph(n)
       );
   // mayanGlyph :: Int -> String
   const mayanGlyph = n =>
       filter(any(compose(not, isNull)),
           transpose(leftPadded(
               showIntAtBase(20, mayanDigit, n, [])
           ))
       );
   // mayanDigit :: Int -> [String]
   const mayanDigit = n =>
       0 !== n ? cons(
           replicateString(rem(n, 5), '●'),
           replicate(quot(n, 5), '━━')
       ) : ['Θ'];
   // FORMATTING -----------------------------------------
   // wikiTable :: Dict -> a -> String
   const wikiTable = opts => rows => {
       const colWidth = () =>
           'colwidth' in opts ? (
               '|style="width:' + opts.colwidth + ';"'
           ) : ;
       return 0 < rows.length ? (
           '{| ' + ['class', 'style'].reduce(
               (a, k) => k in opts ? (
                   a + k + '="' + opts[k] + '" '
               ) : a, 
           ) + '\n' + rows.map(
               (row, i) => row.map(
                   x => (0 === i ? (
                       colWidth() + '| '
                   ) : '|') + (x.toString() || ' ')
               ).join('\n')
           ).join('\n|-\n') + '\n|}'
       ) : ;
   };
   // leftPadded :: String -> String
   const leftPadded = xs => {
       const w = maximum(map(length, xs));
       return map(
           x => replicate(w - x.length, ).concat(x),
           xs
       );
   };
   // GENERIC FUNCTIONS ----------------------------------
   // Tuple (,) :: a -> b -> (a, b)
   const Tuple = (a, b) => ({
       type: 'Tuple',
       '0': a,
       '1': b,
       length: 2
   });
   // any :: (a -> Bool) -> [a] -> Bool
   const any = p => xs => xs.some(p);
   // comparing :: (a -> b) -> (a -> a -> Ordering)
   const comparing = f =>
       (x, y) => {
           const
               a = f(x),
               b = f(y);
           return a < b ? -1 : (a > b ? 1 : 0);
       };
   // compose (<<<) :: (b -> c) -> (a -> b) -> a -> c
   const compose = (f, g) => x => f(g(x));
   // concatMap :: (a -> [b]) -> [a] -> [b]
   const concatMap = (f, xs) =>
       xs.reduce((a, x) => a.concat(f(x)), []);
   // cons :: a -> [a] -> [a]
   const cons = (x, xs) =>
       Array.isArray(xs) ? (
           [x].concat(xs)
       ) : 'GeneratorFunction' !== xs.constructor.constructor.name ? (
           x + xs
       ) : ( // Existing generator wrapped with one additional element
           function*() {
               yield x;
               let nxt = xs.next()
               while (!nxt.done) {
                   yield nxt.value;
                   nxt = xs.next();
               }
           }
       )();
   // filter :: (a -> Bool) -> [a] -> [a]
   const filter = (f, xs) => xs.filter(f);
   // foldl1 :: (a -> a -> a) -> [a] -> a
   const foldl1 = (f, xs) =>
       1 < xs.length ? xs.slice(1)
       .reduce(f, xs[0]) : xs[0];
   // isNull :: [a] -> Bool
   // isNull :: String -> Bool
   const isNull = xs =>
       Array.isArray(xs) || ('string' === typeof xs) ? (
           1 > xs.length
       ) : undefined;
   // Returns Infinity over objects without finite length.
   // This enables zip and zipWith to choose the shorter
   // argument when one is non-finite, like cycle, repeat etc
   // length :: [a] -> Int
   const length = xs =>
       (Array.isArray(xs) || 'string' === typeof xs) ? (
           xs.length
       ) : Infinity;
   // map :: (a -> b) -> [a] -> [b]
   const map = (f, xs) =>
       (Array.isArray(xs) ? (
           xs
       ) : xs.split()).map(f);
   // maximum :: Ord a => [a] -> a
   const maximum = xs =>
       0 < xs.length ? (
           foldl1((a, x) => x > a ? x : a, xs)
       ) : undefined;
   //  Ordering: (LT|EQ|GT):
   //  GT: 1 (or other positive n)
   //    EQ: 0
   //  LT: -1 (or other negative n)
   // maximumBy :: (a -> a -> Ordering) -> [a] -> a
   const maximumBy = (f, xs) =>
       0 < xs.length ? (
           xs.slice(1)
           .reduce((a, x) => 0 < f(x, a) ? x : a, xs[0])
       ) : undefined;
   // not :: Bool -> Bool
   const not = b => !b;
   // quot :: Int -> Int -> Int
   const quot = (n, m) => Math.floor(n / m);
   // quotRem :: Int -> Int -> (Int, Int)
   const quotRem = (m, n) =>
       Tuple(Math.floor(m / n), m % n);
   // rem :: Int -> Int -> Int
   const rem = (n, m) => n % m;
   // replicate :: Int -> a -> [a]
   const replicate = (n, x) =>
       Array.from({
           length: n
       }, () => x);
   // replicateString :: Int -> String -> String
   const replicateString = (n, s) => s.repeat(n);
   // showIntAtBase :: Int -> (Int -> [String])
   //               -> Int -> String -> String
   const showIntAtBase = (base, toStr, n, rs) => {
       const go = ([n, d], r) => {
           const r_ = cons(toStr(d), r);
           return 0 !== n ? (
               go(Array.from(quotRem(n, base)), r_)
           ) : r_;
       };
       return go(Array.from(quotRem(n, base)), rs);
   };
   // transpose :: a -> a
   const transpose = tbl => {
       const
           gaps = replicate(
               length(maximumBy(comparing(length), tbl)), []
           ),
           rows = map(xs => xs.concat(gaps.slice(xs.length)), tbl);
       return map(
           (_, col) => concatMap(row => [row[col]], rows),
           rows[0]
       );
   };
   // unlines :: [String] -> String
   const unlines = xs => xs.join('\n');
   // MAIN ---
   return main();

})();</lang>

Output:

Mayan 4005:

━━
━━ Θ ━━

Mayan 8017:

●●
━━
━━
Θ Θ ━━

Mayan 326205:

━━
━━ ━━
●● Θ ━━ ━━ ━━

Mayan 886205:

━━
━━ ━━ ━━
━━ ━━ ━━ ━━ ━━

Mayan 1081439556:

●● ●●● ●●●● ●●● ●●
━━ ━━ ━━ ━━ ━━ ━━ ━━
━━ ━━ ━━ ━━ ━━ ━━ ━━
━━ ━━ ━━ ━━ ━━ ━━ ━━

Mayan 1000000:

━━ ━━ Θ Θ Θ

Mayan 1000000000:

━━ ●●
━━ ━━ ━━
━━ ━━ ━━ Θ Θ Θ Θ

Perl 6

Just a matter of converting to base twenty, then divmod 5 each digit and map to the appropriate glyph. Most of this is display code to deal with the cartouche requirement.

<lang perl6>sub mayan ($int) { $int.polymod(20 xx *).reverse.map: *.polymod(5) }

sub display ($num, @digits) {

   join "\n", '{| style="border-collapse: collapse; border-spacing: 0px;"',
   "|+ $num", '|- style="text-align: center; vertical-align: bottom;"',
   (|@digits.map: {qq!| style="border: 1px solid black; width: 3.25em;" | $_!}),
   '|}'

}

my @output = <4005 8017 326205 886205 1081439556 503491211079>.map:

 { display $_, .&mayan.map: { (join '
', '●' x .[0], '───' xx .[1]) || 'Θ' } }

say @output.join: "\n
\n";</lang>

Output:
4005

───
───
Θ
───


8017
Θ Θ ●●
───
───
───


326205
●● Θ
───
───
───

───
───

───


886205

───

───
───

───
───
───

───
───

───


1081439556

───
───
───
●●
───
───
───
●●●
───
───
───
●●●●
───
───
───
●●●
───
───
───
●●
───
───
───

───
───
───


503491211079
●●●●
───
───
───
●●●
───
───
●●
───
Θ ●●
───
●●●
───
───
●●●●
───
───
───

Python

<lang Python>from functools import (reduce)


  1. main :: IO ()

def main():

   print (
       '\n'.join(map(
           mayanFramed,
           [4005, 8017, 326205, 886205, 1081439556, 1000000, 1000000000]
       ))
   )
  1. MAYAN NUMBERS -------------------------------------------


  1. mayanFramed :: Int -> String

def mayanFramed(n):

   return 'Mayan ' + str(n) + ':\n\n' + (
       wikiTable({
           'class': 'wikitable',
           'style': 'text-align:center; border:2px solid silver'
       })(
           mayanGlyphs(n)
       )
   )


  1. mayanGlyphs :: Int -> String

def mayanGlyphs(n):

   return filter(
       any,
       transpose(leftPadded(
           showIntAtBase(20)(
               lambda n: ['●' * (n % 5)] +
               (['──'] * (n // 5)) if 0 != n else ['Θ']
           )(n)([])
       ))
   )


  1. FORMATTING ----------------------------------------------
  1. wikiTable :: Dict -> a -> String

def wikiTable(opts):

   def go(rows):
       return '{| ' + reduce(
           lambda a, k: (
               a + k + '="' + opts[k] + '" ' if k in opts else a
           ),
           ['class', 'style'],
           
       ) + '\n' + '\n|-\n'.join(
           '| ' + (
               ' || '.join((str(x) or ' ') for x in row)
           ) for row in rows
       ) + '\n|}'
   return lambda xs: go(xs)


  1. GENERIC -------------------------------------------------


  1. leftPadded :: String -> String

def leftPadded(xs):

   w = max(map(len, xs))
   return map(
       lambda x: ([] * (w - len(x))) + x,
       xs
   )


  1. showIntAtBase :: Int -> (Int -> [String]) -> Int -> [String] -> [String]

def showIntAtBase(base):

   def f(toStr, n, rs):
       def go(nd, r):
           n, d = nd
           r_ = [toStr(d)] + r
           return go(divmod(n, base), r_) if 0 != n else r_
       return go(divmod(n, base), rs)
   return lambda toStr: lambda n: lambda rs: (
       f(toStr, n, rs)
   )


  1. transpose :: a -> a

def transpose(xs):

   return list(map(list, zip(*xs)))


if __name__ == '__main__':

   main()</lang>
Output:

Mayan 4005:

──
── Θ ──

Mayan 8017:

●●
──
──
Θ Θ ──

Mayan 326205:

──
── ──
●● Θ ── ── ──

Mayan 886205:

──
── ── ──
── ── ── ── ──

Mayan 1081439556:

●● ●●● ●●●● ●●● ●●
── ── ── ── ── ── ──
── ── ── ── ── ── ──
── ── ── ── ── ── ──

Mayan 1000000:

── ── Θ Θ Θ

Mayan 1000000000:

── ●●
── ── ──
── ── ── Θ Θ Θ Θ

REXX

<lang rexx>/*REXX program converts decimal numbers to the Mayan numbering system (with cartouches).*/ parse arg $ /*obtain optional arguments from the CL*/ if $= then $= 4005 8017 326205 886205, /*Not specified? Then use the default.*/

                172037122592320200101           /*Morse code for MAYAN; egg is a blank.*/
 do j=1  for words($)                           /*convert each of the numbers specified*/
 #= word($, j)                                  /*extract a number from (possible) list*/
 say
 say  center('converting the decimal number '     #     " to a Mayan number:", 90,  '─')
 say
 call $MAYAN   #   '(overlap)'                  /*invoke the  $MAYAN (REXX) subroutine.*/
 say
 end   /*j*/                                    /*stick a fork in it,  we're all done. */</lang>

The   $MAYAN.REX   (REXX program) subroutine can be seen here   ───►   Mayan_numerals\$MAYAN.REX.

output   when using the default inputs:
─────────────────converting the decimal number  4005  to a Mayan number:──────────────────

╔════╦════╦════╗
║    ║    ║    ║
║    ║    ║    ║
║────║    ║    ║
║────║ Θ  ║────║
╚════╩════╩════╝


─────────────────converting the decimal number  8017  to a Mayan number:──────────────────

╔════╦════╦════╦════╗
║    ║    ║    ║ ∙∙ ║
║    ║    ║    ║────║
║    ║    ║    ║────║
║ ∙  ║ Θ  ║ Θ  ║────║
╚════╩════╩════╩════╝


────────────────converting the decimal number  326205  to a Mayan number:─────────────────

╔════╦════╦════╦════╦════╗
║    ║    ║    ║    ║    ║
║    ║    ║────║    ║    ║
║    ║    ║────║────║    ║
║ ∙∙ ║ Θ  ║────║────║────║
╚════╩════╩════╩════╩════╝


────────────────converting the decimal number  886205  to a Mayan number:─────────────────

╔════╦════╦════╦════╦════╗
║    ║    ║    ║    ║    ║
║    ║    ║────║    ║    ║
║    ║────║────║────║    ║
║────║────║────║────║────║
╚════╩════╩════╩════╩════╝


─────────converting the decimal number  172037122592320200101  to a Mayan number:─────────

╔════╦════╦════╦════╦════╦════╦════╦════╦════╦════╦════╦════╦════╦════╦════╦════╗
║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║
║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║
║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║    ║
║────║────║ Θ  ║ ∙  ║────║ Θ  ║────║ ∙  ║────║────║ Θ  ║ ∙  ║────║ Θ  ║────║ ∙  ║
╚════╩════╩════╩════╩════╩════╩════╩════╩════╩════╩════╩════╩════╩════╩════╩════╝

zkl

<lang zkl>var zero=" \u0398 ",one="\u2219", five=String("\u2500"*4,"\n"), fill=" \n"; var ds=T(" "," \u2219 "," \u2219\u2219 ","\u2219\u2219\u2219 ","\u2219\u2219\u2219\u2219"); fcn mayan(m){ //--> lists of lists of strings (each line of tile)

  m.toString(20).pump(List,fcn(m){		// 4,005 --> "a05"
     bars,dots := m.toInt(20).divr(5);		// "a" --> 10 --> (2,0)
     if(0==bars==dots) return(String(fill*3, zero).split("\n"));  // 0
     String(fill*(3-bars), ds[dots],"\n", five*bars)[0,-1].split("\n") // tile
  })

}</lang> <lang zkl>var vbar="\u2551", hbar="\u2550"*4, ut=(hbar+"\u2566"), bt=(hbar+"\u2569"); fcn displayMayan(m){ // eg 11 is ( ( ),( * ),(----),(----) )

  println("\u2554", ut*(m.len()-1), hbar,"\u2557");  // top
  foreach n in (4){ println(vbar, m.apply("get",n).concat(vbar), vbar) }
  println("\u255a", bt*(m.len()-1), hbar,"\u255d");  // bottom

}</lang> <lang zkl>foreach m in (T(4_005, 8_017, 326_205, 886_205, 503_491_211_079, 88_637_341)){

  println("\n%,d:".fmt(m)); mayan(m):displayMayan(_);

}</lang>

Output:
4,005:
╔════╦════╦════╗
║    ║    ║    ║
║    ║    ║    ║
║────║    ║    ║
║────║ Θ  ║────║
╚════╩════╩════╝

8,017:
╔════╦════╦════╦════╗
║    ║    ║    ║ ∙∙ ║
║    ║    ║    ║────║
║    ║    ║    ║────║
║ ∙  ║ Θ  ║ Θ  ║────║
╚════╩════╩════╩════╝

326,205:
╔════╦════╦════╦════╦════╗
║    ║    ║    ║    ║    ║
║    ║    ║────║    ║    ║
║    ║    ║────║────║    ║
║ ∙∙ ║ Θ  ║────║────║────║
╚════╩════╩════╩════╩════╝

886,205:
╔════╦════╦════╦════╦════╗
║    ║    ║    ║    ║    ║
║    ║    ║────║    ║    ║
║    ║────║────║────║    ║
║────║────║────║────║────║
╚════╩════╩════╩════╩════╝

503,491,211,079:
╔════╦════╦════╦════╦════╦════╦════╦════╦════╗
║∙∙∙∙║    ║    ║    ║    ║    ║    ║    ║∙∙∙∙║
║────║∙∙∙ ║    ║    ║    ║    ║    ║∙∙∙ ║────║
║────║────║ ∙∙ ║    ║    ║    ║ ∙∙ ║────║────║
║────║────║────║ ∙  ║ Θ  ║ ∙  ║────║────║────║
╚════╩════╩════╩════╩════╩════╩════╩════╩════╝

88,637,341:
╔════╦════╦════╦════╦════╦════╦════╗
║    ║    ║    ║∙∙∙∙║    ║    ║    ║
║    ║    ║∙∙∙ ║────║∙∙∙ ║    ║    ║
║    ║ ∙∙ ║────║────║────║ ∙∙ ║    ║
║ ∙  ║────║────║────║────║────║ ∙  ║
╚════╩════╩════╩════╩════╩════╩════╝