Difference between revisions of "Template:Smart lookup"
Jump to navigation
Jump to search
Kevin Wang (talk | contribs) m |
Kevin Wang (talk | contribs) |
||
| Line 1: | Line 1: | ||
| − | <includeonly>{{ | + | <includeonly>{{List lookup helper|{{{1}}}}}{{#vardefine:index|{{{2|1}}}}}<!-- |
| − | + | -->{{#ifexpr:{{#var:index}}<={{#var:length}}<!-- | |
| − | --> | + | if index is less than length of list, return immediately |
| − | + | -->|{{#var:entry_{{#var:index}}}} | |
| − | + | |{{#vardefine:adjusted_index|{{#expr:({{{2|1}}} mod {{#var:index}})}}}}{{#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. | ||
| Line 17: | Line 9: | ||
This behavior was extracted from [[Template:Quick links smart lingo]]. | This behavior was extracted from [[Template:Quick links smart lingo]]. | ||
<pre> | <pre> | ||
| − | {{Smart lookup | + | {{Smart lookup|QBWiki:Quick links/lingo|1}} |
| − | |Quick links lingo | ||
| − | |1 | ||
| − | }} | ||
</pre> | </pre> | ||
| − | {{Smart lookup|Quick links lingo|1}} | + | {{Smart lookup|QBWiki:Quick links/lingo|1}} |
}}</noinclude> | }}</noinclude> | ||
Revision as of 18:58, 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 extracted from Template:Quick links smart lingo.
{{Smart lookup|QBWiki:Quick links/lingo|1}}
Wondering why people keep saying "m"?