max

概要

整数のセットから最大値を返します。

構文

max(<integerList>)

説明

関数は max() 、整数の配列または整数のコンマ区切りのリストから最大値を返します。

例 1 - 整数のコンマ区切りリストから最大値を返す

この構成では、整数の一覧から最大の数値が返されます。

# max.example.1.dsc.config.yaml
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo maximum value
  type: Microsoft.DSC.Debug/Echo
  properties:
    output: "[max(3, 2, 5, 1, 7)]"
dsc config get --file max.example.1.dsc.config.yaml config get
results:
- name: Echo maximum value
  type: Microsoft.DSC.Debug/Echo
  result:
    actualState:
      output: 7
messages: []
hadErrors: false

例 2 - 整数の配列から最大値を返す

この構成は、別のリソース インスタンス への参照 として取得される整数の配列から最大の数をエコーします。 YAML の折りたたまれた複数行構文を使用して、関数をより読みやすくします。

# max.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 maximum integer
  type: Microsoft.DSC.Debug/Echo
  properties:
    output: >-
      [max(
        reference(
          resourceId('Microsoft.DSC.Debug/Echo', 'Echo integer array')
        ).actualState.output
      )]
  dependsOn:
  - "[resourceId('Microsoft.DSC.Debug/Echo', 'Echo integer array')]"
dsc config get --file max.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 maximum integer
  type: Microsoft.DSC.Debug/Echo
  result:
    actualState:
      output: 7

パラメーター

integerList

関数は max() 、整数の 1 つの配列または整数のコンマ区切りの配列を受け取ります。 整数を直接渡す場合は、各整数をコンマで区切ります。 配列オブジェクトを渡すと、関数は 1 つの配列のみを引数として受け取ります。

Type:         [integer, array(integer)]
Required:     true
MinimumCount: 1
MaximumCount: 18446744073709551615

出力

関数は max() 、入力の最大値を表す 1 つの整数を返します。

Type: integer