Template talk:Max
Appearance
(Redirected from Template talk:Max/sandbox)
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)
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}} | 5 | 5 |
{{max|-7|5|}} | 5 | 5 |
{{max|-7|5|8}} | 8 | 8 |
{{max|40*41|300+30}} | 1640 | 1640 |
{{max|100+10|300+30|200+20}} | 330 | 330 |
If people know of other edge cases, I would welcome additional testing. Dragons flight (talk) 17:24, 21 February 2013 (UTC)
- 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)