diff --git a/content/docs/howto/use-the-built-in-function-list-concat-to-concatenate-lists/en.md b/content/docs/howto/use-the-built-in-function-list-concat-to-concatenate-lists/en.md new file mode 100644 index 000000000..337d641a4 --- /dev/null +++ b/content/docs/howto/use-the-built-in-function-list-concat-to-concatenate-lists/en.md @@ -0,0 +1,67 @@ +--- +title: Using the built-in function "list.Concat" to concatenate lists +tags: +- commented cue +authors: +- jpluscplusm +toc_hide: true +--- + +This [Commented CUE]({{< relref "docs/howto#commented-cue-guides" >}}) +demonstrates how to use the built-in function +[`list.Concat`](https://pkg.go.dev/cuelang.org/go/pkg/list#Concat) +to concatenate a list of lists. + +{{{with code "en" "cc"}}} +exec cue export -e output +cmp stdout out +-- file.cue -- +package example + +import "list" + +// list.Concat concatenates lists in the order +// they are provided, including re-processing +// repeated references. +output: list.Concat([listA, listB, listC, listB]) + +listA: [1, 2, 3, 4] +listB: ["hello", "world"] +listC: [{ + a: 10 + b: "10" +}, { + a: 11 + b: "11" +}, { + a: 12 + b: "12" +}] +-- out -- +[ + 1, + 2, + 3, + 4, + "hello", + "world", + { + "a": 10, + "b": "10" + }, + { + "a": 11, + "b": "11" + }, + { + "a": 12, + "b": "12" + }, + "hello", + "world" +] +{{{end}}} + +## Related content + +- The [`list`](https://pkg.go.dev/cuelang.org/go/pkg/list) built-in package diff --git a/content/docs/howto/use-the-built-in-function-list-concat-to-concatenate-lists/gen_cache.cue b/content/docs/howto/use-the-built-in-function-list-concat-to-concatenate-lists/gen_cache.cue new file mode 100644 index 000000000..4d94f42a0 --- /dev/null +++ b/content/docs/howto/use-the-built-in-function-list-concat-to-concatenate-lists/gen_cache.cue @@ -0,0 +1,18 @@ +package site +{ + content: { + docs: { + howto: { + "use-the-built-in-function-list-concat-to-concatenate-lists": { + page: { + cache: { + code: { + cc: "C/lyu4iZepLe25cdtwys4yqUHAgG/bwTCED+emeN8u0=" + } + } + } + } + } + } + } +} diff --git a/content/docs/howto/use-the-built-in-function-list-concat-to-concatenate-lists/page.cue b/content/docs/howto/use-the-built-in-function-list-concat-to-concatenate-lists/page.cue new file mode 100644 index 000000000..e2c75b4df --- /dev/null +++ b/content/docs/howto/use-the-built-in-function-list-concat-to-concatenate-lists/page.cue @@ -0,0 +1,3 @@ +package site + +content: docs: howto: "use-the-built-in-function-list-concat-to-concatenate-lists": {} diff --git a/hugo/content/en/docs/howto/use-the-built-in-function-list-concat-to-concatenate-lists/index.md b/hugo/content/en/docs/howto/use-the-built-in-function-list-concat-to-concatenate-lists/index.md new file mode 100644 index 000000000..1ade2a6ec --- /dev/null +++ b/hugo/content/en/docs/howto/use-the-built-in-function-list-concat-to-concatenate-lists/index.md @@ -0,0 +1,68 @@ +--- +title: Using the built-in function "list.Concat" to concatenate lists +tags: +- commented cue +authors: +- jpluscplusm +toc_hide: true +--- + +This [Commented CUE]({{< relref "docs/howto#commented-cue-guides" >}}) +demonstrates how to use the built-in function +[`list.Concat`](https://pkg.go.dev/cuelang.org/go/pkg/list#Concat) +to concatenate a list of lists. + +{{< code-tabs >}} +{{< code-tab name="file.cue" language="cue" area="top-left" >}} +package example + +import "list" + +// list.Concat concatenates lists in the order +// they are provided, including re-processing +// repeated references. +output: list.Concat([listA, listB, listC, listB]) + +listA: [1, 2, 3, 4] +listB: ["hello", "world"] +listC: [{ + a: 10 + b: "10" +}, { + a: 11 + b: "11" +}, { + a: 12 + b: "12" +}] +{{< /code-tab >}} +{{< code-tab name="TERMINAL" language="" type="terminal" area="top-right" >}} +$ cue export -e output +[ + 1, + 2, + 3, + 4, + "hello", + "world", + { + "a": 10, + "b": "10" + }, + { + "a": 11, + "b": "11" + }, + { + "a": 12, + "b": "12" + }, + "hello", + "world" +] +{{< /code-tab >}} +{{< /code-tabs >}} + +## Related content + +- The [`list`](https://pkg.go.dev/cuelang.org/go/pkg/list) built-in package