diff --git a/content/docs/howto/use-the-built-in-functions-list-avg-list-max-list-min-list-sum-to-summarise-lists-of-numbers/en.md b/content/docs/howto/use-the-built-in-functions-list-avg-list-max-list-min-list-sum-to-summarise-lists-of-numbers/en.md new file mode 100644 index 000000000..e1fb2487a --- /dev/null +++ b/content/docs/howto/use-the-built-in-functions-list-avg-list-max-list-min-list-sum-to-summarise-lists-of-numbers/en.md @@ -0,0 +1,53 @@ +--- +title: Using the built-in functions "list.Avg", "list.Max", "list.Min, and "list.Sum" to summarise lists of numbers +tags: +- commented cue +authors: +- jpluscplusm +toc_hide: true +--- + +This [Commented CUE]({{< relref "docs/howto#commented-cue-guides" >}}) +demonstrates how to use the built-in functions +[`list.Avg`](://pkg.go.dev/cuelang.org/go/pkg/list#Avg), +[`list.Max`](https://pkg.go.dev/cuelang.org/go/pkg/list#Max), +[`list.Min`](https://pkg.go.dev/cuelang.org/go/pkg/list#Min), and +[`list.Sum`](https://pkg.go.dev/cuelang.org/go/pkg/list#Sum) +to calculate various simple summary statistics for a list of numbers including +the list's arithmetic mean, its maximum and minimum values, and the sum of its +values. + +{{{with code "en" "cc"}}} +#location left right + +exec cue eval +cmp stdout out +-- file.cue -- +package example + +import "list" + +sum: list.Sum(_data) +min: list.Min(_data) +max: list.Max(_data) +mean: list.Avg(_data) + +_data: [ + -0.00000000001, + 0, + 1, + 5, + 10, + 42, + -999, +] +-- out -- +sum: -941.00000000001 +min: -999 +max: 42 +mean: -134.4285714285728571428571428571429 +{{{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-functions-list-avg-list-max-list-min-list-sum-to-summarise-lists-of-numbers/gen_cache.cue b/content/docs/howto/use-the-built-in-functions-list-avg-list-max-list-min-list-sum-to-summarise-lists-of-numbers/gen_cache.cue new file mode 100644 index 000000000..b4c37375a --- /dev/null +++ b/content/docs/howto/use-the-built-in-functions-list-avg-list-max-list-min-list-sum-to-summarise-lists-of-numbers/gen_cache.cue @@ -0,0 +1,18 @@ +package site +{ + content: { + docs: { + howto: { + "use-the-built-in-functions-list-avg-list-max-list-min-list-sum-to-summarise-lists-of-numbers": { + page: { + cache: { + code: { + cc: "TgSrJixcjWKbsdlTRP/0WA3aaNkj4LaclRlkeQ/xGqg=" + } + } + } + } + } + } + } +} diff --git a/content/docs/howto/use-the-built-in-functions-list-avg-list-max-list-min-list-sum-to-summarise-lists-of-numbers/page.cue b/content/docs/howto/use-the-built-in-functions-list-avg-list-max-list-min-list-sum-to-summarise-lists-of-numbers/page.cue new file mode 100644 index 000000000..22c665988 --- /dev/null +++ b/content/docs/howto/use-the-built-in-functions-list-avg-list-max-list-min-list-sum-to-summarise-lists-of-numbers/page.cue @@ -0,0 +1,3 @@ +package site + +content: docs: howto: "use-the-built-in-functions-list-avg-list-max-list-min-list-sum-to-summarise-lists-of-numbers": {} diff --git a/hugo/content/en/docs/howto/use-the-built-in-functions-list-avg-list-max-list-min-list-sum-to-summarise-lists-of-numbers/index.md b/hugo/content/en/docs/howto/use-the-built-in-functions-list-avg-list-max-list-min-list-sum-to-summarise-lists-of-numbers/index.md new file mode 100644 index 000000000..e882f7d9b --- /dev/null +++ b/hugo/content/en/docs/howto/use-the-built-in-functions-list-avg-list-max-list-min-list-sum-to-summarise-lists-of-numbers/index.md @@ -0,0 +1,52 @@ +--- +title: Using the built-in functions "list.Avg", "list.Max", "list.Min, and "list.Sum" to summarise lists of numbers +tags: +- commented cue +authors: +- jpluscplusm +toc_hide: true +--- + +This [Commented CUE]({{< relref "docs/howto#commented-cue-guides" >}}) +demonstrates how to use the built-in functions +[`list.Avg`](://pkg.go.dev/cuelang.org/go/pkg/list#Avg), +[`list.Max`](https://pkg.go.dev/cuelang.org/go/pkg/list#Max), +[`list.Min`](https://pkg.go.dev/cuelang.org/go/pkg/list#Min), and +[`list.Sum`](https://pkg.go.dev/cuelang.org/go/pkg/list#Sum) +to calculate various simple summary statistics for a list of numbers including +the list's arithmetic mean, its maximum and minimum values, and the sum of its +values. + +{{< code-tabs >}} +{{< code-tab name="file.cue" language="cue" area="left" >}} +package example + +import "list" + +sum: list.Sum(_data) +min: list.Min(_data) +max: list.Max(_data) +mean: list.Avg(_data) + +_data: [ + -0.00000000001, + 0, + 1, + 5, + 10, + 42, + -999, +] +{{< /code-tab >}} +{{< code-tab name="TERMINAL" language="" type="terminal" area="right" >}} +$ cue eval +sum: -941.00000000001 +min: -999 +max: 42 +mean: -134.4285714285728571428571428571429 +{{< /code-tab >}} +{{< /code-tabs >}} + +## Related content + +- The [`list`](https://pkg.go.dev/cuelang.org/go/pkg/list) built-in package