Template:數列/doc
Template:NoteTATemplate:Documentation subpage Template:Lua
概要
根據指定數學式(以Template:Tl為基礎)產生一個數列。
參數及使用方法
{{數列 | 顯示模式,$1會填入數列項 | 從哪項開始列 | 列到哪一項 | 以x表示數列}}
- 例如要產生一個平方數
x^2的數列,可以使用以下語法 - 亦可以指定最初項,定義遞迴的數列,例如斐波那契数列,表達式以
last(1)+last(2)表示前兩項的和,並定義參數Template:Para,完整語法如下:
關於數列表達式可用語法詳見以下說明: Template:HideH
語法
Template:複變運算/語法 Template:HideF
模板數據
Template:TemplateDataHeader Template:HideH <templatedata> { "params": { "1": { "label": "顯示模式", "description": "顯示模式,$會填入數列項", "type": "content", "required": true }, "2": { "aliases": [ "min" ], "label": "數列首項", "description": "數列第一項的x值", "type": "number", "required": true }, "3": { "aliases": [ "max" ], "label": "數列末項", "description": "數列最後一項的x值", "type": "number", "required": true }, "4": { "label": "運算式", "description": "以x表達數列的運算式", "type": "string", "required": true }, "5": { "label": "運算式的變數", "description": "若運算式的變數非x,則可以用此參數指定運算式的變數", "default": "x", "type": "string" }, "class": { "label": "運算數字模式", "description": "要運算的數字模式,可以是實數、cmath(複數)、qmath(四元數)、no calc(不計算)、mathtag(以<math>輸出)或直接寫Module:模組名稱.運算庫來指定使用特定模組來運算。", "type": "string", "default": "cmath" }, "series": { "label": "是否為級數", "description": "若需要計算數列的級數,將此參數設為是。", "type": "boolean", "default": "no" }, "raw_value": { "label": "是否為原始資料", "description": "是否以運算結果的原始資料輸出", "type": "boolean", "default": "no" }, "delnowiki": { "label": "是否去除", "description": "是否去除參數1中的<nowiki>", "type": "boolean", "default": "no" }, "delmsgnw": { "label": "是否去除msgnw", "description": "是否去除參數1中的msgnw", "type": "boolean", "default": "no" }, "last1": { "label": "首項的前1項", "type": "string" }, "last2": { "label": "首項的前2項", "type": "string" }, "preprocess": { "label": "是否視為維基代碼", "description": "是否將整個結果視為維基代碼再次呼叫解析。用於參數1有要將結果輸進模板的情況", "type": "boolean", "default": "no" }, "template": { "label": "模板模式", "description": "是否啟用模板模式。使用模板模式時,運算式請使用維基代碼表達要列的數列,當中的$會自動替換成數值", "type": "boolean", "default": "no" } }, "paramOrder": [ "1", "2", "3", "4", "5", "class", "series", "raw_value", "delnowiki", "delmsgnw", "last1", "last2", "preprocess", "template" ], "description": "產生一個數列" } </templatedata> {{HideF}} === 模板模式 === 當表達式無法表達,只能透過模板呼叫時,可以使用模板模式: :<code><nowiki>{{數列 | 顯示模式,$1會填入數列項 | 從哪項開始列 | 列到哪一項 | 使用維基代碼表達要列的數列,當中的$會自動替換成數值 | template=yes}}
- 例如要產生一個Template:Tlx的數列,可以使用以下語法
- 作為數列的模板語法必須防止提前解析,可使用跳脫字元
\及魔術字Template:Tlx:
範例
| ||||
| Template:0Template:0Template:0Template:0Template:0Template:0 | Template:Tlx | → | 「Template:數列」 | |
| ||||
| Template:0Template:0Template:0Template:0Template:0Template:0 | {| class=wikitable
{{數列|{{!!}} $ |1|10|質數(x)}}
|}
|
→ |
Template:數列 | |