Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

Jump to content

Template talk:Max

Page contents not supported in other languages.
Add topic
From Wikipedia, the free encyclopedia
Latest comment: 13 years ago by Dragons flight in topic Lua version

Lua version

[edit]

I've created a Lua implementation that allows for arbitrary number of parameters:

  • {{#invoke:Math | max | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 }} = 8

If one wants to ensure that expression such as 4*41 and 600+30 are evaluated correctly (as is the current practice), then they need to be wrapped in {{#expr: }}

  • {{#invoke:Math | max | {{#expr: 4*41 }} | {{#expr: 600+30 }} }} = 630

So it should be possible to replace the current template with:

  • {{#invoke:Math|max| {{#expr:{{{1}}}}} | {{#expr:{{{2}}}}} | {{#expr:{{{3}}}}} }}
See even better version below. Dragons flight (talk) 01:43, 22 February 2013 (UTC)Reply

Which will duplicate current functionality, or add additional parameters to extend functionality.

Test Cases:

Test{{max}}{{max/sandbox}}
{{max}}
{{max|}}
{{max|-7}}-7-7
{{max|-7|}}-7-7
{{max|-7|5}}55
{{max|-7|5|}}55
{{max|-7|5|8}}88
{{max|40*41|300+30}}16401640
{{max|100+10|300+30|200+20}}330330

If people know of other edge cases, I would welcome additional testing. Dragons flight (talk) 17:24, 21 February 2013 (UTC)Reply

I've made a better version that doesn't require the use of #expr:, and can take a practically limitless numbers of arguments:
  • {{max/sandbox|1|2|3|4|5|6|7|8|9|10|11|12|13|14}} = 3
Yay to new technology. Dragons flight (talk) 01:42, 22 February 2013 (UTC)Reply