Difference between revisions of "Template:Quick links smart in-jokes"
Jump to navigation
Jump to search
Kevin Wang (talk | contribs) (Created page with "{{#vardefine:quip|{{#explode:{{:QBWiki:Quick links/in-jokes}}|*|{{{1|1}}}|1000}}}}{{#if:{{#var:quip}}|{{#var:quip}}}}<noinclude> Extract individual quips from the list at Q...") |
Kevin Wang (talk | contribs) |
||
| Line 1: | Line 1: | ||
| − | {{#vardefine: | + | {{#vardefine:index|{{{1|1}}}}}{{#if:{{Quick links in-jokes|{{#var:index}}}} |
| + | |{{Quick links in-jokes|{{#var:index}}}} | ||
| + | |{{#vardefine:minindex|{{#var:index}}}}{{#vardefine:maxindex|1}}<!-- | ||
| + | just for fun, binary search for last list entry if out of bounds | ||
| + | -->{{#dowhile: | ||
| + | |{{#ifexpr:{{#var:maxindex}}+1<{{#var:minindex}}|continue}} | ||
| + | |{{#if:{{Quick links in-jokes|{{#var:index}}}} | ||
| + | <!--undershoot-->|{{#ifexpr:{{#var:index}}>{{#var:maxindex}}|{{#vardefine:maxindex|{{#var:index}}}}}} | ||
| + | <!-- overshoot-->|{{#ifexpr:{{#var:index}}<{{#var:minindex}}|{{#vardefine:minindex|{{#var:index}}}}}} | ||
| + | }} | ||
| + | {{#vardefine:index|{{#expr:floor(({{#var:maxindex}}+{{#var:minindex}})/2)}}}} | ||
| + | }}{{#vardefine:adjusted_index|{{#expr:({{{1|1}}} mod {{#var:index}})}}}}{{#ifexpr:{{#var:adjusted_index}}=0|{{#vardefine:adjusted_index|{{#var:index}}}}}}{{Quick links in-jokes|{{#var:adjusted_index}}}} | ||
| + | }}<noinclude> | ||
| + | Incremental improvement on [[Template:Quick links in-jokes]] | ||
| − | + | When index i <= # of in-jokes quips, return quip straight away. If i > #, it'll wrap around (mod #). | |
| − | + | {| class="wikitable" | |
| − | + | ! Index | |
| − | + | ! Quip | |
| − | + | |- | |
| + | |1||{{Quick links smart in-jokes|1}} Test sentence | ||
| + | |- | ||
| + | |2||{{Quick links smart in-jokes|2}} Test sentence | ||
| + | |- | ||
| + | |3||{{Quick links smart in-jokes|3}} Test sentence | ||
| + | |} | ||
</noinclude> | </noinclude> | ||
Revision as of 12:39, 7 December 2021
Wondering about quizbowl's fascination with Dog with a Blog? Incremental improvement on Template:Quick links in-jokes
When index i <= # of in-jokes quips, return quip straight away. If i > #, it'll wrap around (mod #).
| Index | Quip |
|---|---|
| 1 | Wondering about quizbowl's fascination with Dog with a Blog? Test sentence |
| 2 | Interested in the significance of capybaras? Test sentence |
| 3 | Ever notice how frequently quizbowlers use the verb "barge"? Test sentence |