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.
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
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.
I hate to spoil your fun, but that won't work. We have the recursion detector enabled for a reason.
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.
I hate to spoil your fun, but that won't work. We have the recursion detector enabled for a reason. -- Ilmari Karonen
Luckily, i don't want to be standing at the "wikimedia servers have problems" [1] message eating my nails to revert a page only because half a dozen of children are visiting the [[first 100.000 numbers factorial]] page some dumb created [2]
1- I subrepticiously remember http://bugs.wikimedia.org/show_bug.cgi?id=3944 is waiting for someone with server access to improve the translation. 2- if someone ''really'' wants that, i can easily fill its mailbox with it, no range problem :-)
wikitech-l@lists.wikimedia.org