-
-
Save jamthief/e0784c8b8c9aff21f82631c2862881ec to your computer and use it in GitHub Desktop.
2->di 3->tri 16->hexakaideca 20->dodeca ... git it?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Language constants. | |
var x = ' hen di tri tetra penta hexa hepta octa ennea deca hendeca dodeca triskaideca tetrakaideca pentakaideca hexakaideca heptakaideca octakaideca enneakaideca icosa'.split(' '); | |
var y = ' ,,icosa,conta ,hecato,diacosio,cosioi ,chilia,diachilia,chilia'.split(' ').map(function(s){return s.split(',')}); | |
var z = x.map(function(x){return x+(x[x.length-1]==='a'?'':'a')}); | |
// Convert any number - up to a few thousand, to a numeric prefix. | |
function grekify(n){ | |
n = String(n); // Greek numbers are deca-mal | |
return x[n] || n && [(n[0]>2?z[n[0]]:''),y[n.length][n[0]>2?3:n[0]],grekify(n.slice(1))].join(''); | |
} | |
// Test: | |
for (i=1;i<30;i++){ | |
console.log(i,grekify(i)); | |
} | |
for (i=30;i<1000;i+=Math.floor(Math.random()*10)){ | |
console.log(i,grekify(i)); | |
} | |
for (i=1;i<=1<<10;i=i<<1){ | |
console.log(i,grekify(i)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment