2018-05-12 18:39:29 +02:00
|
|
|
---
|
2020-08-15 03:51:06 +02:00
|
|
|
layout: "language"
|
2018-12-20 05:35:11 +01:00
|
|
|
page_title: "chunklist - Functions - Configuration Language"
|
2018-05-12 18:39:29 +02:00
|
|
|
sidebar_current: "docs-funcs-collection-chunklist"
|
|
|
|
description: |-
|
|
|
|
The chunklist function splits a single list into fixed-size chunks, returning
|
|
|
|
a list of lists.
|
|
|
|
---
|
|
|
|
|
|
|
|
# `chunklist` Function
|
|
|
|
|
|
|
|
`chunklist` splits a single list into fixed-size chunks, returning a list
|
|
|
|
of lists.
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
chunklist(list, chunk_size)
|
|
|
|
```
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
```
|
|
|
|
> chunklist(["a", "b", "c", "d", "e"], 2)
|
|
|
|
[
|
|
|
|
[
|
|
|
|
"a",
|
|
|
|
"b",
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"c",
|
|
|
|
"d",
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"e",
|
|
|
|
],
|
|
|
|
]
|
|
|
|
> chunklist(["a", "b", "c", "d", "e"], 1)
|
|
|
|
[
|
|
|
|
[
|
|
|
|
"a",
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"b",
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"c",
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"d",
|
|
|
|
],
|
|
|
|
[
|
|
|
|
"e",
|
|
|
|
],
|
|
|
|
]
|
|
|
|
```
|