github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/docs/job-specification/hcl2/functions/collection/zipmap.mdx (about) 1 --- 2 layout: docs 3 page_title: zipmap - Functions - Configuration Language 4 description: |- 5 The zipmap function constructs a map from a list of keys and a corresponding 6 list of values. 7 --- 8 9 # `zipmap` Function 10 11 `zipmap` constructs a map from a list of keys and a corresponding list of 12 values. 13 14 ```hcl 15 zipmap(keyslist, valueslist) 16 ``` 17 18 Both `keyslist` and `valueslist` must be of the same length. `keyslist` must 19 be a list of strings, while `valueslist` can be a list of any type. 20 21 Each pair of elements with the same index from the two lists will be used 22 as the key and value of an element in the resulting map. If the same value 23 appears multiple times in `keyslist` then the value with the highest index 24 is used in the resulting map. 25 26 ## Examples 27 28 ```shell-session 29 > zipmap(["a", "b"], [1, 2]) 30 { 31 "a" = 1, 32 "b" = 2, 33 } 34 ```