Skip to content

Instantly share code, notes, and snippets.

jamthief / grekify.js
Created July 19, 2016 16:27 — forked from bitdivine/grekify.js
2->di 3->tri 16->hexakaideca 20->dodeca ... git it?
// 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 ={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('');