摘要
返回整数数组或逗号分隔的整数列表中的最小值。
语法
min(<integerList>)
说明
函数 min
从整数数组或逗号分隔的整数列表返回最小值。
示例
示例 1 - 从逗号分隔的整数列表中返回最小值
此配置返回整数列表中的最小数字。
# min.example.1.dsc.config.yaml
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Echo minimum value
type: Test/Echo
properties:
output: "[min(3, 2, 5, 1, 7)]"
dsc config get --document min.example.1.dsc.config.yaml config get
results:
- name: Echo minimum value
type: Test/Echo
result:
actualState:
output: 1
messages: []
hadErrors: false
示例 2 - 从整数数组返回最小值
此配置回显作为对另一个资源实例的 引用 检索的整数数组中的最小数字。 它使用 YAML 的折叠多行语法使函数更具可读性。
# min.example.2.dsc.config.yaml
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Echo integer array
type: Test/Echo
properties:
output:
- 3
- 2
- 5
- 1
- 7
- name: Echo minimum integer
type: Test/Echo
properties:
output: >-
[min(
reference(
resourceId('Test/Echo', 'Echo integer array')
).actualState.output
)]
dependsOn:
- "[resourceId('Test/Echo', 'Echo integer array')]"
dsc config get --document min.example.2.dsc.config.yaml
results:
- name: Echo integer array
type: Test/Echo
result:
actualState:
output:
- 3
- 2
- 5
- 1
- 7
- name: Echo minimum integer
type: Test/Echo
result:
actualState:
output: 1
参数
integerList
函数 min()
需要单个整数数组或逗号分隔的整数数组。 直接传递整数时,用逗号分隔每个整数。 传递数组对象时,函数仅采用单个数组作为参数。 可以使用 createArray () 函数合并多个数组或数组和其他整数。
Type: [integer, array(integer)]
Required: true
MinimumCount: 1
MaximumCount: 18446744073709551615
输出
函数 min()
返回一个整数,表示输入中的最小值。
Type: integer