Mayan numerals: Difference between revisions
Added FreeBASIC
(Added FreeBASIC) |
|||
(10 intermediate revisions by 10 users not shown) | |||
Line 144:
{{trans|Nim}}
<
UL = ‘╔’
UC = ‘╦’
Line 217:
V mayans = digits.map(d -> toMayanNumeral(d))
draw(mayans)
print()</
{{out}}
Line 263:
=={{header|8080 Assembly}}==
<
puts: equ 9
org 100h
Line 387:
d0: db '| $| . $| .. $|... $|....$'
d5: db '|----$'
dn: db '|',13,10,'$'</
{{out}}
Line 430:
|....|----|----|----|----|----|....|----|----|----|----|----|....|
+----+----+----+----+----+----+----+----+----+----+----+----+----+</pre>
=={{header|Amazing Hopper}}==
{{Trans|BASIC}}
<syntaxhighlight lang="c">
#include <basico.h>
algoritmo
muestra=""
obtener total argumentos
cuando ' sea distinto a( 2 ) '{ terminar }
obtener parámetro alfanumérico (2), guardar en 'muestra'
lsimb={}, '" "," . "," .. ","... ","...."'#(utf8("────")), enlistar en 'lsimb'
largo=0, #( largo = len(muestra))
sdígitos={}, separar( muestra, sdígitos, "")
ndígitos=0, #( ndígitos = number(sdígitos) )
m=0, t=0
#( m = largo-1)
// convertir dígitos a base 20,la base de los mayas:
iterar para( j=m, #(j>=1), --j )
iterar para( i=1, #(i<=j), ++i )
bit.and( #(ndígitos[i]), 1 ), por '10',
guardar en 't'
#( ndígitos[i+1] += t )
#( ndígitos[i] = int(ndígitos[i]/2) )
siguiente
siguiente
s=1
iterar mientras ( #( ndígitos[s]==0 && s<largo) )
++s
reiterar
// armar los cartuchos:
imprimir ( #(utf8("╔═════")),#(replicate( utf8("═════"), largo-s) ), #(utf8("═╗")), NL,\
#(utf8("║┌────")),#(replicate( utf8("┬────"), largo-s) ), #(utf8("┐║")), NL )
n=0
iterar para ( l=3, #(l>=0), --l )
imprimir (#(utf8("║")))
iterar para ( i=s, #(i<=largo), ++i )
si ( bit.or ( #(ndígitos[i]), l ), es igual a '0' )
imprimir ( #(utf8("│ Θ ")) )
sino
guardar ' #(ndígitos[i]-5*l) ' en 'n'
si ( #(n>5) )
n=5
sino si ( n, es negativo? )
n=0
fin si
imprimir( #(utf8("│")), #(lsimb[n+1]) )
fin si
siguiente
imprimir (#(utf8("│║")),NL)
siguiente
imprimir ( #(utf8("║└────")),#(replicate( utf8("┴────"), largo-s) ), #(utf8("┘║")), NL,\
#(utf8("╚═════")),#(replicate( utf8("═════"), largo-s) ), #(utf8("═╝")), NL )
saltar
terminar
</syntaxhighlight>
{{out}}
<pre>
$ hopper3 basica/nummaya.bas 4005
╔════════════════╗
║┌────┬────┬────┐║
║│ │ │ │║
║│ │ │ │║
║│────│ │ │║
║│────│ Θ │────│║
║└────┴────┴────┘║
╚════════════════╝
$ hopper3 basica/nummaya.bas 8017
╔═════════════════════╗
║┌────┬────┬────┬────┐║
║│ │ │ │ .. │║
║│ │ │ │────│║
║│ │ │ │────│║
║│ . │ Θ │ Θ │────│║
║└────┴────┴────┴────┘║
╚═════════════════════╝
$ hopper3 basica/nummaya.bas 326205
╔══════════════════════════╗
║┌────┬────┬────┬────┬────┐║
║│ │ │ │ │ │║
║│ │ │────│ │ │║
║│ │ │────│────│ │║
║│ .. │ Θ │────│────│────│║
║└────┴────┴────┴────┴────┘║
╚══════════════════════════╝
$ hopper3 basica/nummaya.bas 886205
╔══════════════════════════╗
║┌────┬────┬────┬────┬────┐║
║│ │ │ │ │ │║
║│ │ │────│ │ │║
║│ │────│────│────│ │║
║│────│────│────│────│────│║
║└────┴────┴────┴────┴────┘║
╚══════════════════════════╝
$ hopper3 basica/nummaya.bas 98380658201233422
╔═══════════════════════════════════════════════════════════════════════╗
║┌────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┐║
║│ │ │ │ │ │ │ │ │ │ .. │ │ │ │ │║
║│ │ │ │ │ │....│ │ │ │────│....│ │ . │ │║
║│ │ │ │ .. │....│────│....│ │ .. │────│────│ │────│ │║
║│ . │....│ Θ │────│────│────│────│....│────│────│────│... │────│ .. │║
║└────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┘║
╚═══════════════════════════════════════════════════════════════════════╝
</pre>
=={{header|APL}}==
{{works with|Dyalog APL}}
<
ds←6 4⍴' . .. ... ....────'
d←{ ⍵=0:4 4⍴¯14↑'Θ'
Line 441 ⟶ 565:
btm←'╚',(1↓∊(≢d)⍴⊂'╩════'),'╝'
top⍪((⊃,/'║',¨d),'║')⍪btm
}</
{{out}}
Line 490 ⟶ 614:
=={{header|AppleScript}}==
Applescript supports only small integers (up to (2^29)-1 = 536870911).
<
use framework "Foundation"
use scripting additions
Line 753 ⟶ 877:
end |λ|
end script
end wikiTable</
{{Out}}
Mayan 4005:
Line 796 ⟶ 920:
|style="width:3em;vertical-align:bottom;"|Θ
|}
=={{header|Arturo}}==
<syntaxhighlight lang="arturo">UL: "╔"
UC: "╦"
UR: "╗"
LL: "╚"
LC: "╩"
LR: "╝"
HB: "═"
VB: "║"
Mayan: [" ", " ∙ ", " ∙∙ ", "∙∙∙ ", "∙∙∙∙"]
M0: " Θ "
M5: "────"
toMayan: function [digit][
result: array.of:4 Mayan\0
if digit = 0 [
result\3: M0
return result
]
d: digit
loop 3..0 'i [
if? d >= 5 [
result\[i]: M5
d: d - 5
]
else [
result\[i]: Mayan\[d]
break
]
]
return result
]
draw: function [mayans][
idx: dec size mayans
prints UL
loop 0..idx 'i [
loop 0..3 'j [
prints HB
]
prints (i < idx)? -> UC -> UR ++ `\n`
]
loop 1..4 'i [
prints VB
loop 0..idx 'j ->
prints mayans\[j]\[dec i] ++ VB
print ""
]
prints LL
loop 0..idx 'i [
loop 0..3 'j ->
prints HB
prints (i < idx)? -> LC -> LR ++ `\n`
]
]
loop [4005, 8017, 326205, 886205, 1081439556] 'n [
print ["Converting" n "to Mayan:"]
digs: digits.base:20 n
mayans: map digs => toMayan
draw mayans
print ""
]</syntaxhighlight>
{{out}}
<pre>Converting 4005 to Mayan:
╔════╦════╦════╗
║ ║ ║ ║
║ ║ ║ ║
║────║ ║ ║
║────║ Θ ║────║
╚════╩════╩════╝
Converting 8017 to Mayan:
╔════╦════╦════╦════╗
║ ║ ║ ║ ∙∙ ║
║ ║ ║ ║────║
║ ║ ║ ║────║
║ ∙ ║ Θ ║ Θ ║────║
╚════╩════╩════╩════╝
Converting 326205 to Mayan:
╔════╦════╦════╦════╦════╗
║ ║ ║ ║ ║ ║
║ ║ ║────║ ║ ║
║ ║ ║────║────║ ║
║ ∙∙ ║ Θ ║────║────║────║
╚════╩════╩════╩════╩════╝
Converting 886205 to Mayan:
╔════╦════╦════╦════╦════╗
║ ║ ║ ║ ║ ║
║ ║ ║────║ ║ ║
║ ║────║────║────║ ║
║────║────║────║────║────║
╚════╩════╩════╩════╩════╝
Converting 1081439556 to Mayan:
╔════╦════╦════╦════╦════╦════╦════╗
║ ∙ ║ ∙∙ ║∙∙∙ ║∙∙∙∙║∙∙∙ ║ ∙∙ ║ ∙ ║
║────║────║────║────║────║────║────║
║────║────║────║────║────║────║────║
║────║────║────║────║────║────║────║
╚════╩════╩════╩════╩════╩════╩════╝</pre>
=={{header|AutoHotkey}}==
<syntaxhighlight lang="autohotkey">MayanNumerals(num){
pwr:=1, obj:=[], grid:=[]
while (num // 20**pwr)
pwr++
while --pwr
{
obj.Push(num // 20**pwr)
num := Mod(num, 20**pwr)
}
obj.Push(num)
cols := obj.count()
loop % cols
{
c := A_Index
loop 4
grid[c, A_Index] := " "
grid[c, 4] := " Θ "
}
for i, v in obj
{
j := 5
loop % v//5
{
j := 5 - A_Index
grid[i, j] := "————"
}
rem := ""
loop % Mod(v, 5)
rem .= "●"
rem := rem = "●" ? " ● " : rem = "●●" ? " ●● " : rem = "●●●" ? "●●● " : rem
if Mod(v, 5)
grid[i, j-1] := rem
}
return grid2table(grid, cols)
}
grid2table(grid, cols){
loop, % cols-1
topRow .= "════╦", bottomRow .= "════╩"
topRow := "╔" topRow "════╗"
bottomRow := "╚" bottomRow "════╝"
loop % 4
{
r := A_Index
loop % cols
result .= "║" grid[A_Index, r]
result .= "║`n"
}
result := topRow "`n" result . bottomRow
return % result
}</syntaxhighlight>
Examples:<syntaxhighlight lang="autohotkey">for i, n in [4005, 8017, 326205, 886205, 194481]
{
x := MayanNumerals(n)
Gui, Font, S12, Consolas
Gui, Add, Text, , % n
Gui, Add, Text, y+0, % x
Gui, Show, y100
MsgBox, 262180, , continue with next number?
IfMsgBox, No
ExitApp
Gui, Destroy
}</syntaxhighlight>
{{out}}
<pre>
4005 8017 326205 886205 194481
╔════╦════╦════╗ ╔════╦════╦════╦════╗ ╔════╦════╦════╦════╦════╗ ╔════╦════╦════╦════╦════╗ ╔════╦════╦════╦════╦════╗
║ ║ ║ ║ ║ ║ ║ ║ ●● ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║ ║ ║————║ ║ ║ ║————║ ║ ║ ║ ║ ║————║ ║ ║ ║ ║ ║ ║ ║ ║
║————║ ║ ║ ║ ║ ║ ║————║ ║ ║ ║————║————║ ║ ║ ║————║————║————║ ║ ║ ║ ║ ● ║ ║ ║
║————║ Θ ║————║ ║ ● ║ Θ ║ Θ ║————║ ║ ●● ║ Θ ║————║————║————║ ║————║————║————║————║————║ ║ ● ║●●●●║————║●●●●║ ● ║
╚════╩════╩════╝ ╚════╩════╩════╩════╝ ╚════╩════╩════╩════╩════╝ ╚════╩════╩════╩════╩════╝ ╚════╩════╩════╩════╩════╝
</pre>
=={{header|BASIC}}==
<
15 FOR I=0 TO 5: READ L$(I): NEXT I
20 LINE INPUT I$
Line 821 ⟶ 1,135:
210 FOR I=S TO M: PRINT "+----";: NEXT I: PRINT "+"
220 END
230 DATA " "," . "," .. ","... ","....","----"</
{{out}}
Line 872 ⟶ 1,186:
=={{header|BCPL}}==
<
let reads(v) be
Line 941 ⟶ 1,255:
mayan(v)
$) repeat
$)</
{{out}}
<pre style='height:50ex;'>Number? 4005
Line 980 ⟶ 1,294:
=={{header|C}}==
<
#include <string.h>
#include <stdint.h>
Line 1,069 ⟶ 1,383:
free(m);
return 0;
}</
{{out}}
Line 1,108 ⟶ 1,422:
|....|----|----|----|----|----|....|
+----+----+----+----+----+----+----+</pre>
=={{header|C++}}==
<syntaxhighlight lang="c++">
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>
const std::vector<std::string> MAYAN_DIGITS = { " Θ ", " ∙ ", " ∙∙ ", "∙∙∙ ", "∙∙∙∙", "────" };
const std::string BLANK = " ";
std::unordered_map<std::string, std::string> BORDER { { "horizontal_beam", "═" }, { "vertical_beam", "║" },
{ "lower_left", "╚" }, { "lower_central", "╩" }, { "lower_right", "╝" },
{ "upper_left", "╔" }, { "upper_central", "╦" }, { "upper_right", "╗" } };
std::vector<int32_t> to_base20(const int32_t& number) {
std::vector<int32_t> result;
result.emplace_back(number % 20);
int32_t n = number / 20;
while ( n != 0 ) {
result.emplace_back(n % 20);
n /= 20;
}
std::reverse(result.begin(), result.end());
return result;
}
std::vector<std::string> to_mayan_numeral(int32_t digit) {
std::vector<std::string> result(4, BLANK);
if ( digit == 0 ) {
result[3] = MAYAN_DIGITS[0];
return result;
}
for ( int32_t i = 3; i >= 0; --i ) {
if ( digit >= 5 ) {
result[i] = MAYAN_DIGITS[5];
digit -= 5;
} else {
result[i] = ( digit == 0 ) ? BLANK : MAYAN_DIGITS[digit];
break;
}
}
return result;
}
void display(const std::vector<std::vector<std::string>>& numerals) {
const int32_t index = numerals.size() - 1;
std::cout << BORDER["upper_left"];
for ( int32_t i = 0; i <= index; ++i ) {
for ( int32_t j = 0; j <= 3; ++j ) {
std::cout << BORDER["horizontal_beam"];
}
if ( i < index ) {
std::cout << BORDER["upper_central"];
} else {
std::cout << BORDER["upper_right"] << std::endl;
}
}
for ( int32_t i = 1; i <= 4; ++i ) {
std::cout << BORDER["vertical_beam"];
for ( int32_t j = 0; j <= index; ++j ) {
std::cout << numerals[j][i - 1] + BORDER["vertical_beam"];
}
std::cout << std::endl;
}
std::cout << BORDER["lower_left"];
for ( int32_t i = 0; i <= index; ++i ) {
for ( int32_t j = 0; j <= 3; ++j ) {
std::cout << BORDER["horizontal_beam"];
}
if ( i < index ) {
std::cout << BORDER["lower_central"];
} else {
std::cout << BORDER["lower_right"] << std::endl;
}
}
}
int main() {
for ( const int32_t& base10 : { 4'005, 8'017, 326'205, 886'205, 1'081'439'556 } ) {
std::cout << "Base 10 number, " << base10 << " to Mayan:" << std::endl;
std::vector<int32_t> digits = to_base20(base10);
std::vector<std::vector<std::string>> mayans;
for ( const int32_t& digit : digits ) {
std::vector<std::string> mayan = to_mayan_numeral(digit);
mayans.push_back(mayan);
}
display(mayans);
std::cout << std::endl;
}
}
</syntaxhighlight>
{{ out }}
<pre>
Base 10 number, 4005 to Mayan:
╔════╦════╦════╗
║ ║ ║ ║
║ ║ ║ ║
║────║ ║ ║
║────║ Θ ║────║
╚════╩════╩════╝
Base 10 number, 8017 to Mayan:
╔════╦════╦════╦════╗
║ ║ ║ ║ ∙∙ ║
║ ║ ║ ║────║
║ ║ ║ ║────║
║ ∙ ║ Θ ║ Θ ║────║
╚════╩════╩════╩════╝
Base 10 number, 326205 to Mayan:
╔════╦════╦════╦════╦════╗
║ ║ ║ ║ ║ ║
║ ║ ║────║ ║ ║
║ ║ ║────║────║ ║
║ ∙∙ ║ Θ ║────║────║────║
╚════╩════╩════╩════╩════╝
Base 10 number, 886205 to Mayan:
╔════╦════╦════╦════╦════╗
║ ║ ║ ║ ║ ║
║ ║ ║────║ ║ ║
║ ║────║────║────║ ║
║────║────║────║────║────║
╚════╩════╩════╩════╩════╝
Base 10 number, 1081439556 to Mayan:
╔════╦════╦════╦════╦════╦════╦════╗
║ ∙ ║ ∙∙ ║∙∙∙ ║∙∙∙∙║∙∙∙ ║ ∙∙ ║ ∙ ║
║────║────║────║────║────║────║────║
║────║────║────║────║────║────║────║
║────║────║────║────║────║────║────║
╚════╩════╩════╩════╩════╩════╩════╝
</pre>
=={{header|CLU}}==
<
base20 = proc (n: bigint) returns (sequence[int])
Line 1,159 ⟶ 1,613:
n: bigint := bigint$parse(sequence[string]$bottom(get_argv()))
stream$puts(po, mayan(base20(n)))
end start_up</
{{out}}
<pre>$ ./mayan 4005
Line 1,202 ⟶ 1,656:
=={{header|Cowgol}}==
<
include "argv.coh";
Line 1,277 ⟶ 1,731:
(n, arg) := AToI(arg);
if n <= 0 then Error(); end if;
print_mayan(n as uint32);</
{{out}}
Line 1,318 ⟶ 1,772:
=={{header|F_Sharp|F#}}==
<
// Mayan numerals. Nigel Galloway: February 19th., 2021
let N=[|"│ ";"│. ";"│.. ";"│... ";"│....";"│~~~~"|]
Line 1,329 ⟶ 1,783:
printfn "┘"
[4005L;8017L;326205L;886205L]|>List.iter(fun n->printfn "%d" n; mayan n)
</syntaxhighlight>
{{out}}
<pre>
Line 1,362 ⟶ 1,816:
</pre>
=={{header|Factor}}==
<
sequences ;
IN: rosetta-code.mayan-numerals
Line 1,395 ⟶ 1,849:
{ 4005 8017 326205 886205 } [ .mayan ] each ;
MAIN: mayan-numerals</
{{out}}
Mayan 4005:
Line 1,435 ⟶ 1,889:
|}
=={{header|
<syntaxhighlight lang="vbnet">Dim As Integer i, j, m, n, s, v
Dim As String maya(5), num
For i = 0 To 5
Read maya(i)
Next i
Const ul = Chr(201), uc = Chr(203), ur = Chr(187), ll = Chr(200)
Const lc = Chr(202), lr = Chr(188), hb = Chr(205), vb = Chr(186)
Dim As Longint numbers(0 To ...) = {4005, 8017, 326205, 886205, 1081439556, 18380658207197784}
For v = 0 To Ubound(numbers)
num = Str(numbers(v))
Print "Converting"; numbers(v); " to Mayan:"
m = Len(num)
Redim As Integer D(m)
For i = 1 To m
D(i) = Val(Mid(num,i,1))
Next i
For j = m-1 To 1 Step -1
For i = 1 To j
D(i+1) += 10*(D(i) And 1)
D(i) \= 2
Next i
Next j
s = 1
Do While D(s) = 0 And s < m
s += 1
Loop
For i = s To m
Print Iif(i < m-1, ul+hb+hb+hb+hb, uc+hb+hb+hb+hb);
Next i
Print ur
For j = 3 To 0 Step -1
For i = s To m
If (D(i) Or j) = 0 Then
Print vb + " @ ";
Else
n = D(i)-5*j
If n > 5 Then
n = 5
Elseif n < 0 Then
n = 0
End If
Print vb; maya(n);
End If
Next i
Print vb
Next j
For i = s To m
Print Iif(i < m-1, ll+hb+hb+hb+hb, lc+hb+hb+hb+hb);
Next i
Print lr + Chr(10) '"+"
Next v
Sleep
Data " "," . "," .. ","... ","....","----"</syntaxhighlight>
{{out}}
<pre>Same as BASIC entry.</pre>
=={{header|Fōrmulæ}}==
{{FormulaeEntry|page=https://formulae.org/?script=examples/Mayan_numerals}}
=={{header|Go}}==
<
import (
Line 1,549 ⟶ 2,060:
fmt.Println()
}
}</
{{out}}
Line 1,595 ⟶ 2,106:
=={{header|Haskell}}==
<
import Data.List (intercalate, transpose)
import qualified Data.Map.Strict as M
Line 1,733 ⟶ 2,244:
leftPadded xs =
let w = maximum (length <$> xs)
in ((<>) =<< flip replicate [] . (-) w . length) <$> xs</
{{Out}}
Mayan 4005:
Line 1,901 ⟶ 2,412:
=={{header|J}}==
<
digit =: (elems{~5:<.0:>.15 10 5 0-~])`((4 4$_14{.'@')&[)@.(0&=)
mayan =: ":@(digit each@(20&#.^:_1))</
{{out}}
Line 1,962 ⟶ 2,472:
=={{header|Java}}==
Unicode characters used. See <code>Character.toChars</code>.
<
import java.math.BigInteger;
Line 2,144 ⟶ 2,654:
}
</syntaxhighlight>
{{out}}
<pre>
Line 2,229 ⟶ 2,739:
=={{header|JavaScript}}==
<
'use strict';
Line 2,446 ⟶ 2,956:
// MAIN ---
return main();
})();</
{{Out}}
Mayan 4005:
Line 2,624 ⟶ 3,134:
'''Works with gojq, the Go implementation of jq'''
{{trans|Wren}}
<
{ ul: "╔",
uc: "╦",
Line 2,648 ⟶ 3,158:
# decimal number to base-20 array, most significant digit first
def dec2vig:
[recurse(if . >=
| reverse;
Line 2,683 ⟶ 3,192:
4005, 8017, 326205, 886205, 1081439556
| decimal2mayan</
{{out}}
<pre>
Line 2,733 ⟶ 3,242:
=={{header|Julia}}==
<h4> First version, using a style sheet, output to html, with the capability of proper style within the browser.</h4>
<
mayan_glyphs(x, y) = (x == 0 && y == 0) ? "\n<td>Θ</td>\n" : "<td>\n" * "●" ^ x * "<br />\n───" ^ y * "</td>\n"
Line 2,770 ⟶ 3,279:
testmayan()
</syntaxhighlight>
<h4> Version 2, using local wiki style table formatting: translation of style code from the Raku version. </h4>
<
inttomayan(n) = (s = string(n, base=20); map(ch -> reverse(divrem(parse(Int, ch, base=20), 5)), split(s, "")))
Line 2,790 ⟶ 3,299:
testmayan()
</syntaxhighlight>
{{out}}
Line 2,861 ⟶ 3,370:
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<
MakeLengthFive[ci_String] := Module[{c},
c = If[EvenQ[StringLength[ci]], ci <> " ", ci];
Line 2,887 ⟶ 3,396:
MayanNumeral[326205]
MayanNumeral[886205]
MayanNumeral[1337]</
{{out}}
Outputs a graphical representation of the cartouches.
Line 2,894 ⟶ 3,403:
{{trans|Go}}
Free adaptation of the Go version.
<syntaxhighlight lang="nim">
import algorithm
Line 2,970 ⟶ 3,479:
let mayans = digits.mapIt(it.toMayanNumeral)
mayans.draw()
echo ""</
{{out}}
Line 3,017 ⟶ 3,526:
{{trans|Raku}}
{{libheader|ntheory}}
<
my $t_style = '"border-collapse: separate; text-align: center; border-spacing: 3px 0px;"';
Line 3,051 ⟶ 3,560:
}
print join "\n<br>\n", @output;</
{{out}}
{| style="border-collapse: separate; text-align: center; border-spacing: 3px 0px;"
Line 3,105 ⟶ 3,614:
=={{header|PL/M}}==
<
THIS PROGRAM RUNS UNDER CP/M AND TAKES THE NUMBER ON THE COMMAND LINE */
Line 3,203 ⟶ 3,712:
CALL EXIT;
EOF</
{{out}}
<pre style='height:50ex;'>A>MAYAN 4005
Line 3,248 ⟶ 3,757:
{{trans|Raku}}
Three-way output controlled by the first two constants.
<!--<
<span style="color: #000080;font-style:italic;">-- demo\rosetta\Mayan_numerals.exw</span>
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- (file i/o [when as_html is true])</span>
Line 3,369 ⟶ 3,878:
<span style="color: #0000FF;">{}</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">wait_key</span><span style="color: #0000FF;">()</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<!--</
{{out}}
With inline_css set to false. Note these are always height-4.
Line 3,578 ⟶ 4,087:
=={{header|PureBasic}}==
<
Dim pl$(5)
pl$(0)=" Θ " : pl$(1)=" • " : pl$(2)=" •• "
Line 3,645 ⟶ 4,154:
ConsoleLocate(0,#START_Y+7) : Print("Dezimal = "+i$)
ConsoleLocate(0,#START_Y+8) : Print("Vigesimal= "+j$)
ForEver</
{{out}}
<pre>MAYAN: ?
Line 3,694 ⟶ 4,203:
=={{header|Python}}==
{{Works with|Python|3.7}}
<
from functools import (reduce)
Line 3,831 ⟶ 4,340:
# MAIN ---
if __name__ == '__main__':
main()</
{{Out}}
Mayan numeral representations of various integers:
Line 3,921 ⟶ 4,430:
These don't particularly resemble the Mayan cartouche, more like mahjong tiles actually. It would have been ''so'' much easier and more compact if I could have put all the styling into a CSS file instead of inlining it, but oh well, it was entertaining to do.
<syntaxhighlight lang="raku"
my $t-style = '"border-collapse: separate; text-align: center; border-spacing: 3px 0px;"';
my $c-style = '"border: solid black 2px;background-color: #fffff0;border-bottom: double 6px;'~
Line 3,939 ⟶ 4,448:
say @output.join: "\n$joiner\n";
</syntaxhighlight>
{{out}}
Line 4,020 ⟶ 4,529:
Or, plain old text mode. Not as pretty, but still serviceable.
<syntaxhighlight lang="raku"
use Terminal::Boxer;
my $joiner = "\n";
Line 4,034 ⟶ 4,543:
}
say @output.join: $joiner;</
{{out}}
Line 4,095 ⟶ 4,604:
=={{header|REXX}}==
<
parse arg $ /*obtain optional arguments from the CL*/
if $='' then $= 4005 8017 326205 886205, /*Not specified? Then use the default.*/
Line 4,107 ⟶ 4,616:
call $MAYAN # '(overlap)' /*invoke the $MAYAN (REXX) subroutine.*/
say
end /*j*/ /*stick a fork in it, we're all done. */</
The '''$MAYAN.REX''' (REXX program) subroutine can be seen here ───► [[Mayan_numerals\$MAYAN.REX]].
Line 4,162 ⟶ 4,671:
</pre>
=={{header|Ruby}}==
<
if numbers.length == 0
puts
Line 4,182 ⟶ 4,691:
end
end
end
puts(('+----' * digits5s1s.length) + '+')
Line 4,190 ⟶ 4,699:
puts(num)
maya_print(num)
end</
{{out}}
<pre>$ ruby mayan.rb 4005 8017 326205 886205 4294967296
Line 4,230 ⟶ 4,739:
=={{header|Rust}}==
<
const FIVE: &str = "——";
const ZERO: &str = "Θ";
Line 4,298 ⟶ 4,807:
}
mayan
}</
{{out}}
<pre>
Line 4,361 ⟶ 4,870:
{{trans|Go}}
{{libheader|Wren-fmt}}
<
var ul = "╔"
Line 4,436 ⟶ 4,945:
draw.call(mayans)
System.print()
}</
{{out}}
Line 4,482 ⟶ 4,991:
=={{header|zkl}}==
<
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)
Line 4,490 ⟶ 4,999:
String(fill*(3-bars), ds[dots],"\n", five*bars)[0,-1].split("\n") // tile
})
}</
<
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
}</
<
println("\n%,d:".fmt(m)); mayan(m):displayMayan(_);
}</
{{out}}
<pre style="height:40ex">
Line 4,552 ⟶ 5,061:
The Raku numerals look so good, let's copy them.
{{trans|Raku}}
<
t_style=0''"border-collapse: separate; text-align: center; border-spacing: 3px 0px;"',
c_style=0''"border: solid black 2px;background-color: #fffff0;border-bottom: double 6px;'
Line 4,573 ⟶ 5,082:
}).replace("!","<br>") : display(m,_)
})
.concat("\n<br>\n").println();</
{{out}}
{| style="border-collapse: separate; text-align: center; border-spacing: 3px 0px;"
|