Changes

Jump to navigation Jump to search
5.542 bayt əlavə edildi ,  22:50, 29 iyul 2020
Səhifəni '<noinclude><!-- -============================================================= - Strlen_quick - Get length of a character string quickly -================================...' ilə yarat
<noinclude><!--
-=============================================================
- Strlen_quick - Get length of a character string quickly
-=============================================================
-- (see NOTES at bottom)
--></noinclude>{{
#ifeq: x{{{1}}}|x{{padleft:{{{1}}}|20}}
| {{#ifeq: x{{{1}}}|x{{padleft:{{{1}}}|30}}
| {{#ifeq: x{{{1}}}|x{{padleft:{{{1}}}|40}}
| {{#switch: x{{{1}}}
| {{padleft:|41|x{{{1}}}}} = 40
| {{padleft:|42|x{{{1}}}}} = 41
| {{padleft:|43|x{{{1}}}}} = 42
| {{padleft:|44|x{{{1}}}}} = 43
| {{padleft:|45|x{{{1}}}}} = 44
| {{padleft:|46|x{{{1}}}}} = 45
| {{padleft:|47|x{{{1}}}}} = 46
| {{padleft:|48|x{{{1}}}}} = 47
| {{padleft:|49|x{{{1}}}}} = 48
| {{padleft:|50|x{{{1}}}}} = 49
| {{padleft:|51|x{{{1}}}}} = 50
| {{padleft:|52|x{{{1}}}}} = 51
| {{padleft:|53|x{{{1}}}}} = 52
| {{padleft:|54|x{{{1}}}}} = 53
| {{padleft:|55|x{{{1}}}}} = 54
| {{padleft:|56|x{{{1}}}}} = 55
| {{padleft:|57|x{{{1}}}}} = 56
| {{padleft:|58|x{{{1}}}}} = 57
| {{padleft:|59|x{{{1}}}}} = 58
| {{padleft:|60|x{{{1}}}}} = 59
| {{padleft:|61|x{{{1}}}}} = 60
| {{padleft:|62|x{{{1}}}}} = 61
| {{padleft:|63|x{{{1}}}}} = 62
| {{padleft:|64|x{{{1}}}}} = 63
| {{padleft:|65|x{{{1}}}}} = 64
| {{padleft:|66|x{{{1}}}}} = 65
| {{padleft:|67|x{{{1}}}}} = 66
| {{padleft:|68|x{{{1}}}}} = 67
| {{padleft:|69|x{{{1}}}}} = 68
| {{padleft:|70|x{{{1}}}}} = 69
| {{padleft:|71|x{{{1}}}}} = 70
| {{padleft:|72|x{{{1}}}}} = 71
| {{padleft:|73|x{{{1}}}}} = 72
| {{padleft:|74|x{{{1}}}}} = 73
| {{padleft:|75|x{{{1}}}}} = 74
| {{padleft:|76|x{{{1}}}}} = 75
| {{padleft:|77|x{{{1}}}}} = 76
| {{padleft:|78|x{{{1}}}}} = 77
| {{padleft:|79|x{{{1}}}}} = 78
| {{padleft:|80|x{{{1}}}}} = 79
| {{padleft:|81|x{{{1}}}}} = 80
| #default= {{{extra|-1}}} <!--when > 80 -->
}}<!--endsw 40's++ -->
| {{#switch: x{{{1}}}
| {{padleft:|31|x{{{1}}}}} = 30
| {{padleft:|32|x{{{1}}}}} = 31
| {{padleft:|33|x{{{1}}}}} = 32
| {{padleft:|34|x{{{1}}}}} = 33
| {{padleft:|35|x{{{1}}}}} = 34
| {{padleft:|36|x{{{1}}}}} = 35
| {{padleft:|37|x{{{1}}}}} = 36
| {{padleft:|38|x{{{1}}}}} = 37
| {{padleft:|39|x{{{1}}}}} = 38
| #default= 39
}}<!--endsw 30's-->
}}<!--endifeq 40-->
| {{#switch: x{{{1}}}
| {{padleft:|21|x{{{1}}}}} = 20
| {{padleft:|22|x{{{1}}}}} = 21
| {{padleft:|23|x{{{1}}}}} = 22
| {{padleft:|24|x{{{1}}}}} = 23
| {{padleft:|25|x{{{1}}}}} = 24
| {{padleft:|26|x{{{1}}}}} = 25
| {{padleft:|27|x{{{1}}}}} = 26
| {{padleft:|28|x{{{1}}}}} = 27
| {{padleft:|29|x{{{1}}}}} = 28
| #default= 29
}}<!--endsw 20's-->
}}<!--endifeq 30-->
| {{#ifeq: x{{{1}}}|x{{padleft:{{{1}}}|10}}
| {{#switch: x{{{1}}}
| {{padleft:|18|x{{{1}}}}} = 17
| {{padleft:|19|x{{{1}}}}} = 18
| {{padleft:|17|x{{{1}}}}} = 16
| {{padleft:|20|x{{{1}}}}} = 19
| {{padleft:|16|x{{{1}}}}} = 15
| {{padleft:|15|x{{{1}}}}} = 14
| {{padleft:|14|x{{{1}}}}} = 13
| {{padleft:|13|x{{{1}}}}} = 12
| {{padleft:|12|x{{{1}}}}} = 11
| #default= 10 <!--when >= 10 and none of above-->
}}<!--endsw 10's++ -->
| {{#switch: x{{{1}}}
| {{padleft:|10|x{{{1}}}}} = 9
| {{padleft:|9|x{{{1}}}}} = 8
| {{padleft:|8|x{{{1}}}}} = 7
| {{padleft:|7|x{{{1}}}}} = 6
| {{padleft:|6|x{{{1}}}}} = 5
| {{padleft:|5|x{{{1}}}}} = 4
| {{padleft:|4|x{{{1}}}}} = 3
| {{padleft:|3|x{{{1}}}}} = 2
| #default= 1
}}<!--endsw 1's-->
}}<!--endifeq 10-->
}}<!--endifeq 20--><noinclude><!--
-=============================================================
--NOTES
-- See talk-page: [[Template_talk:Strlen_quick]].
--
-- [ These comments are skipped by <noinclude> so they will
-- be omitted & not sent in a formatted Internet page. ]
--
-- NOTE A1: This template counts the length of string {1} by
-- comparing with the string truncated to 'n' long in a
-- #switch for each set of lengths of {padleft:|n|{1} }.
-- The first match will exit the #switch with the length
-- number and exit the nested end-ifs. Max length is 70.
--
-- NOTE N2: This template was designed to use minimal levels
-- as 5, to avoid the "expansion depth limit" when used
-- in very large templates. By comparison, {str_len} was
-- using over 9-13 levels of 40 total, during 2009-2011.
--
-- NOTE P3: To speed the results, the check for length is based
-- on probability of an average length of 17/18, as found
-- in Wikipedia titles, where length 5 is as rare as 31
-- or longer. The average search is 6.5 uses of {padleft}
-- but the weighted average for actual titles is near 4.
-- When most strings are > 49, then use {str_len}.
--
-- NOTE S4: This template CANNOT be subst-substituted by using
-- {{subst:strlen_short|...}} to save only the results, or
-- {{{{{|safesubst:}}}strlen_short}} using blank parameter.
--
--------------------------------------------------------------
--HISTORY:
--30Jan2011 Created to get length quickly in few nest levels.
--31Jan2011 Removed spurious newline before <noinclude>.
--31Jan2011 Set to return {{{extra|-1}}} when > 70.
--18May2011 Expanded to return {{{extra|-1}}} when > 80.
--
-->{{doc}}
[[Kateqoriya:Şablonlar:Sətirlərlə iş]]
</noinclude>

Naviqasiya menyusu