Nick Jenkins wrote:
There are two conditional functions and a mathematical expression function.
Cool! Dibs on [[:en:Template:Factorial]] :
{{if: {{{1}}}=1 | 1 | {{expr: {{{1}}} * {{{{PAGENAME}} | {{expr: {{{1}}} - 1}} }} }} }}
... or something like that.
But why stop there? There are probably many mathematical constructs that can be implemented now (think how many functions there are in Excel or OpenOffice's Calc just waiting to be implemented) ... A whole world of recursive mathematical functions awaits! :-)
Then the message we leave for bored schoolkids ( http://en.wikipedia.org/wiki/Template:Test ) can be updated to include this: "Did you know you can do some of your maths homework using the Wikipedia? Click to find out how".
But why stop there? Coupled with a big enough library of mathematical constructs, you can stop thinking of MediaWiki as being primarily about collaborative text editing, and start to think of it also as a remote sandboxed interpreter / code-executor. You could potentially, for example, write a client that does protein-folding calculations or crunches SETI data using the Wikipedia as the CPU. Of course, it'd be wildly impractical (massively slow, prone to failure due to network problems or site outages, etc), but it might hold a certain "just to see if it can be done" type of attraction.
The supported operators (roughly in order of precedence) are:
In all seriousness, if you're going to have "=", you might as well have the "<" and ">" and "<=" and ">=" operators too (someone is bound to ask for them).
All the best, Nick.
Only half in jest, why not go the whole hog and embed full support for a suitable language, such as...
<scheme>(date-to-string (+ 1 (string-to-date (get-wiki-variable "DATE"))))</scheme>
(with a suitably limited environment, and other sandboxing precautions, of course).
-- Neil