Изменения

Перейти к: навигация, поиск

Шаблон:!str len/core

3419 байт добавлено, 17:13, 10 марта 2012
Нет описания правки
{{{{{|safesubst:}}}#switch: {{{3|}}}

| hundreds = <noinclude><!-- 0xx-4xx, using linear search since most strings will probably be less than 100 bytes. --></noinclude>
{{{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| 100 }} <noinclude><!--str >= x--></noinclude>
| {{{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| 200 }}
| {{{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| 300 }}
| {{{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| 400 }}
| 4
| 3
}}
| 2
}}
| 1
}}
| <noinclude><!-- Don't return 0, since tens and ones don't want a leading 0 in parameter 2. --></noinclude>
}}

| tens = <noinclude><!-- x0x-x9x, using linear search for 0x-3x, binary search for 4x-9x, since most strings will probably be 0-39 bytes. --></noinclude>
{{{2|}}}{{
{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| {{{2|}}}10 }} <noinclude><!--str >= x--></noinclude>
| {{{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| {{{2|}}}20 }}
| {{{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| {{{2|}}}30 }}
| {{{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| {{{2|}}}40 }}
| {{{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| {{{2|}}}60 }}
| {{{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| {{{2|}}}80 }}
| {{{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| {{{2|}}}90 }}
| 9
| 8
}}
| {{{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| {{{2|}}}70 }}
| 7
| 6
}}
}}
| {{{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| {{{2|}}}50 }}
| 5
| 4
}}
}}
| 3
}}
| 2
}}
| 1
}}
| {{{{{|safesubst:}}}#if:{{{2|}}}|0}} <noinclude><!-- Only return 0 if >=100, since ones don't want a leading 0 in parameter 2. --></noinclude>
}}

| ones = <noinclude><!-- xx0-xx9, using binary search. --></noinclude>
{{{2|}}}{{
{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| {{{2|}}}4 }} <noinclude><!--str >= x--></noinclude>
| {{{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| {{{2|}}}6 }}
| {{{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| {{{2|}}}8 }}
| {{{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| {{{2|}}}9 }}
| 9
| 8
}}
| {{{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| {{{2|}}}7 }}
| 7
| 6
}}
}}
| {{{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| {{{2|}}}5 }}
| 5
| 4
}}
}}
| {{{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| {{{2|}}}2 }}
| {{{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| {{{2|}}}3 }}
| 3
| 2
}}
| {{{{{|safesubst:}}}#ifeq: "{{{1|}}}" | {{{{{|safesubst:}}}padleft:"{{{1|}}}"| {{{2|}}}1 }}
| 1
| 0
}}
}}
}}

}}<noinclude>
{{documentation}}
<!-- Add categories and interwikis to the /doc subpage, not here! -->
</noinclude>
Анонимный участник

Навигация