Difference between revisions of "Template:Smart lookup"
Jump to navigation
Jump to search
Kevin Wang (talk | contribs) |
Kevin Wang (talk | contribs) m |
||
| (One intermediate revision by the same user not shown) | |||
| Line 3: | Line 3: | ||
if index is less than length of list, return immediately | if index is less than length of list, return immediately | ||
-->|{{#var:entry_{{#var:index}}}} | -->|{{#var:entry_{{#var:index}}}} | ||
| − | |{{#vardefine:adjusted_index|{{#expr:({{ | + | |{{#vardefine:adjusted_index|{{#expr:({{#var:index}} mod {{#var:length}})+1}}}}{{#ifexpr:{{#var:adjusted_index}}=0|{{#vardefine:adjusted_index|{{#var:index}}}}}}{{#var:entry_{{#var:adjusted_index}}}} |
}}</includeonly><noinclude>{{Template doc| | }}</includeonly><noinclude>{{Template doc| | ||
Given a list and an index ''i'', return the (''i'' mod ''N'')-th entry in the list. | Given a list and an index ''i'', return the (''i'' mod ''N'')-th entry in the list. | ||
| − | This behavior was extracted from [[Template:Quick links smart lingo]]. | + | This behavior was originally extracted from [[Template:Quick links smart lingo|Quick links smart lingo]] and was refactored to use [[Template:List lookup helper|List lookup helper]]. |
<pre> | <pre> | ||
{{Smart lookup|QBWiki:Quick links/lingo|1}} | {{Smart lookup|QBWiki:Quick links/lingo|1}} | ||
| + | |||
| + | {{Smart lookup|QBWiki:Quick links/lingo|99}} | ||
</pre> | </pre> | ||
{{Smart lookup|QBWiki:Quick links/lingo|1}} | {{Smart lookup|QBWiki:Quick links/lingo|1}} | ||
| + | |||
| + | {{Smart lookup|QBWiki:Quick links/lingo|99}} | ||
}}</noinclude> | }}</noinclude> | ||
Latest revision as of 21:00, 14 December 2025
Template documentation
Given a list and an index i, return the (i mod N)-th entry in the list.
This behavior was originally extracted from Quick links smart lingo and was refactored to use List lookup helper.
{{Smart lookup|QBWiki:Quick links/lingo|1}}
{{Smart lookup|QBWiki:Quick links/lingo|99}}
Wondering why people keep saying "m"?
Heard something about the "canon"?