„Wikipedia:Lua/Modul/Expr/en“ – Versionsunterschied
Erscheinungsbild
Inhalt gelöscht Inhalt hinzugefügt
Setup |
+ base62 |
||
Zeile 5: | Zeile 5: | ||
The standard functions are supposed to be used in <code>#invoke</code> and retrieve those parameters. Whitespace ahead and after any content is ignored. |
The standard functions are supposed to be used in <code>#invoke</code> and retrieve those parameters. Whitespace ahead and after any content is ignored. |
||
; base62 {{Anker|base62}} |
|||
: Coding und decoding according to[[Base62]]. |
|||
:* '''1''' – figure to be converted |
|||
:* '''2''' – ''(optional)'' <code>D2B</code> for decimal-into-base62; Vorgabe: base62-into-decimal |
|||
; max {{Anker|max}} |
; max {{Anker|max}} |
||
: Retrieve maximum of a set of figures. |
: Retrieve maximum of a set of figures. |
||
Zeile 32: | Zeile 36: | ||
=== Examples (test page) === |
=== Examples (test page) === |
||
A [[Wikipedia:Lua/Modul/Expr/ |
A [[Wikipedia:Lua/Modul/Expr/Test|test page]] illustrates practical use.</onlyinclude> |
||
== {{Anker|Lua}} Functions for Lua modules (API) == |
== {{Anker|Lua}} Functions for Lua modules (API) == |
Version vom 10. November 2014, 11:39 Uhr
Vorlagenprogrammierung | Diskussionen | Lua | Test | Unterseiten | |||
Modul | Deutsch | English
|
Modul: | Dokumentation |
Expr
– Module with functions for any kind of expression in addition to the functionality offered by #expr
parser functions.
Functions for templates
The standard functions are supposed to be used in #invoke
and retrieve those parameters. Whitespace ahead and after any content is ignored.
- base62
- Coding und decoding according toBase62.
- 1 – figure to be converted
- 2 – (optional)
D2B
for decimal-into-base62; Vorgabe: base62-into-decimal
- max
- Retrieve maximum of a set of figures.
- All unnamed parameters are used for extremum calculation.
- The return value is an empty string (nothing), if no parameter at all or only empty values were provided. An error message for invalid
#expr
might occur as well. Otherwise that is the determined number in the specified formatting. - min
- Retrieve minimum in the same way as max.
Direct transclusion in templates
- TemplateMax
- Like max, but specific to Template:Max – use all parameters of the template around.
- TemplateMin
- Like min, but specific to Template:Min – use all parameters of the template around.
Unicode minus
The minus sign is treated as follows:
- On input values they may be used at will.
- If any input value contains a Unicode minus U+2212, this encoding will be used in the result.
- Optional
minus=1
Use Unicode minus only for resulting string. - Optional
minus=-
Use ASCII hyphen only for resulting string.
A result with Unicode minus is by nature always a string.
Examples (test page)
A test page illustrates practical use.
Functions for Lua modules (API)
All functions documented above may be used via require()
in other Modules:
local lucky, Expr = pcall( require, "Module:Expr" )
if lucky then
Expr = Expr.Expr
else
-- Error; Expr contains error message
return "<span class='error'>" .. Expr .. "</span>"
end
Then there is available:
- Expr( f, a )
f
– string with function name, as abovea
– table with parameter assignments- Values are not supposed to be of string type, but may contain a number itself.
- Return values may be of type number or could be strings or
false
.
Usage
General library; no limitations.
Dependencies
None.