开发者

How can I name Tuples?

Is there a language agnostic algorithm to name tuples?

Specifically, I want the following function:

  1 => Single
  2 => Double
  3 => Triple
  4 => Quadruple
    ...
 10 => Decuple
    ...
100 => Centuple

First of all, is this human-language independent? For example, will that be understood in Spain and Russia?

Secondly, what is the most efficient way to generate this list?

开发者_运维问答

Edit

Just to clarify:

  1. This is not for Tuples in the programming sense, but for a tournament system: Single-elimination, Double-elimination, and etc.

  2. I can do translations, I'm just wondering if there was an algorithm that would lend itself well to translations.


It sounds like you just want a function for converting from what's used in your system (1, 2, 3, etc) to a nice UI-friendly printable string. If you want it to work for non-English languages then you probably shouldn't have this function at all. Let the Spanish-speaker decide what a nice spanish user-friendly wording is.

If I were writing the function, I'd go to "Quadruple Elimination" only and past that just use "5x Elimination", "6x Elimination" instead. That seems nicer to read to me than some of the awkward sounding later tuple words.

There isn't a nice algorithm you could use for this, as it's not an algorithmic thing.

String[4] tupleWords = [ "", "Single", "Double", "Triple", "Quadruple" ];
String getTupleWord(int number) {
    if ( 1 <= number <= 4 ) { 
        return tupleWords[number];
    } else {
        return number+"x";
    }
}

is the best you could do.


The only language independent prefixes are going to be the SI ones, and even those aren't really truly language independent.

http://en.wikipedia.org/wiki/Si_units

I'm pretty sure that 'tuple' notation is going to require translation for every language you want to use.


What about "Tuple of 10", etc?


This is entirely language-dependent. One trick I like to use in this type of situation is to reword the terminology so it's language-independent. So here I might refactor the UI to read something more like "Number of Elimination Rounds: N" with a number instead of putting a dropdown with "Single", "Double", etc.

Even if you want to do this, I think for your application, if you have to type them all out by hand, it wouldn't be so bad. Are you really ever going to have a centuple-elimination tournament? ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜