-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a Commented CUE guide demonstrating how to use list.Concat to concatenate lists. Preview-Path: /docs/howto/use-the-built-in-function-list-concat-to-concatenate-lists/ Signed-off-by: Jonathan Matthews <[email protected]> Change-Id: I482a2a8669841b96069e87b74e68a7c3f01ee878 Dispatch-Trailer: {"type":"trybot","CL":1174726,"patchset":18,"ref":"refs/changes/26/1174726/18","targetBranch":"alpha"}
- Loading branch information
1 parent
cda6ab4
commit 1921319
Showing
4 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
...ent/docs/howto/use-the-built-in-function-list-concat-to-concatenate-lists/en.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
18 changes: 18 additions & 0 deletions
18
content/docs/howto/use-the-built-in-function-list-concat-to-concatenate-lists/gen_cache.cue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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=" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
content/docs/howto/use-the-built-in-function-list-concat-to-concatenate-lists/page.cue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package site | ||
|
||
content: docs: howto: "use-the-built-in-function-list-concat-to-concatenate-lists": {} |
68 changes: 68 additions & 0 deletions
68
.../docs/howto/use-the-built-in-function-list-concat-to-concatenate-lists/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |