概要
傳回整數陣列的最小值,或以逗號分隔的整數清單。
語法
min(<integerList>)
描述
函 min 式會從整數陣列或以逗號分隔的整數清單傳回最小值。
範例
範例 1 - 從以逗號分隔的整數列表傳回最小值
此組態會從整數清單中傳回最小的數位。
# min.example.1.dsc.config.yaml
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo minimum value
type: Microsoft.DSC.Debug/Echo
properties:
output: "[min(3, 2, 5, 1, 7)]"
dsc config get --file min.example.1.dsc.config.yaml config get
results:
- name: Echo minimum value
type: Microsoft.DSC.Debug/Echo
result:
actualState:
output: 1
messages: []
hadErrors: false
範例 2 - 從整數陣列傳回最小值
此組態會從擷取為另一個資源實例 參考 的整數數位中,回應最小的數位。 它會使用 YAML 的折疊多行語法,讓函式更容易閱讀。
# min.example.2.dsc.config.yaml
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo integer array
type: Microsoft.DSC.Debug/Echo
properties:
output:
- 3
- 2
- 5
- 1
- 7
- name: Echo minimum integer
type: Microsoft.DSC.Debug/Echo
properties:
output: >-
[min(
reference(
resourceId('Microsoft.DSC.Debug/Echo', 'Echo integer array')
).actualState.output
)]
dependsOn:
- "[resourceId('Microsoft.DSC.Debug/Echo', 'Echo integer array')]"
dsc config get --file min.example.2.dsc.config.yaml
results:
- name: Echo integer array
type: Microsoft.DSC.Debug/Echo
result:
actualState:
output:
- 3
- 2
- 5
- 1
- 7
- name: Echo minimum integer
type: Microsoft.DSC.Debug/Echo
result:
actualState:
output: 1
參數
integerList
函 min() 式需要整數的單一陣列或以逗號分隔的整數陣列。 當您直接傳遞整數時,請以逗號分隔每個整數。 當您傳遞陣列物件時,函式只會接受單一陣列做為自變數。 您可以使用 createArray () 函式來結合多個數位或陣列和其他整數。
Type: [integer, array(integer)]
Required: true
MinimumCount: 1
MaximumCount: 18446744073709551615
輸出
函式會 min() 傳回代表輸入中最小值的單一整數。
Type: integer