Skip to content

Instantly share code, notes, and snippets.

@yyuu
Created July 15, 2011 12:46
Show Gist options
  • Save yyuu/1084613 to your computer and use it in GitHub Desktop.
Save yyuu/1084613 to your computer and use it in GitHub Desktop.
fucking cardinal conversion in awk
function int2(str, card, rec) {
if(!card) card=10;
i = index("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", toupper(substr(str, 1, 1)))-1;
if(length(str) < 2) {
return rec*card+i;
} else {
return int2(substr(str, 2), card, rec*card+i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment