Documentation ¶
Overview ¶
Package list contains functions for manipulating and examining lists.
Index ¶
- func Avg(xs []*internal.Decimal) (*internal.Decimal, error)
- func Concat(a []cue.Value) ([]cue.Value, error)
- func Contains(a []cue.Value, v cue.Value) bool
- func Drop(x []cue.Value, n int) ([]cue.Value, error)
- func FlattenN(xs cue.Value, depth int) ([]cue.Value, error)
- func IsSorted(list []cue.Value, cmp cue.Value) bool
- func IsSortedStrings(a []string) bool
- func MatchN(list []cue.Value, n pkg.Schema, matchValue pkg.Schema) (bool, error)
- func Max(xs []*internal.Decimal) (*internal.Decimal, error)
- func MaxItems(list pkg.List, n int) (bool, error)
- func Min(xs []*internal.Decimal) (*internal.Decimal, error)
- func MinItems(list pkg.List, n int) (bool, error)
- func Product(xs []*internal.Decimal) (*internal.Decimal, error)
- func Range(start, limit, step *internal.Decimal) ([]*internal.Decimal, error)
- func Repeat(x []cue.Value, count int) ([]cue.Value, error)
- func Reverse(x []cue.Value) []cue.Value
- func Slice(x []cue.Value, i, j int) ([]cue.Value, error)
- func Sort(list []cue.Value, cmp cue.Value) (sorted []cue.Value, err error)
- func SortStable(list []cue.Value, cmp cue.Value) (sorted []cue.Value, err error)deprecated
- func SortStrings(a []string) []string
- func Sum(xs []*internal.Decimal) (*internal.Decimal, error)
- func Take(x []cue.Value, n int) ([]cue.Value, error)
- func UniqueItems(a []cue.Value) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Concat ¶ added in v0.3.0
Concat takes a list of lists and concatenates them.
Concat([a, b, c]) is equivalent to
[for x in a {x}, for x in b {x}, for x in c {x}]
func Drop ¶ added in v0.0.10
Drop reports the suffix of list x after the first n elements, or [] if n > len(x).
For instance:
Drop([1, 2, 3, 4], 2)
results in
[3, 4]
func FlattenN ¶ added in v0.0.12
FlattenN reports a flattened sequence of the list xs by expanding any elements depth levels deep. If depth is negative all elements are expanded.
For instance:
FlattenN([1, [[2, 3], []], [4]], 1)
results in
[1, [2, 3], [], 4]
func IsSorted ¶ added in v0.1.0
IsSorted tests whether a list is sorted.
See Sort for an example comparator.
func IsSortedStrings ¶ added in v0.1.0
IsSortedStrings tests whether a list is a sorted lists of strings.
func MatchN ¶
MatchN is a validator that checks that the number of elements in the given list that unifies with the schema "matchValue" matches "n". "n" may be a number constraint and does not have to be a concrete number. Likewise, "matchValue" will usually be a non-concrete value.
func Range ¶ added in v0.0.12
Range generates a list of numbers using a start value, a limit value, and a step value.
For instance:
Range(0, 5, 2)
results in
[0, 2, 4]
func Repeat ¶ added in v0.3.0
Repeat returns a new list consisting of count copies of list x.
For instance:
Repeat([1, 2], 2)
results in
[1, 2, 1, 2]
func Reverse ¶ added in v0.10.0
Reverse reverses a list.
For instance:
Reverse([1, 2, 3, 4])
results in
[4, 3, 2, 1]
func Slice ¶ added in v0.0.10
Slice extracts the consecutive elements from list x starting from position i up till, but not including, position j, where 0 <= i < j <= len(x).
For instance:
Slice([1, 2, 3, 4], 1, 3)
results in
[2, 3]
func Sort ¶ added in v0.1.0
Sort sorts data while keeping the original order of equal elements. It does O(n*log(n)) comparisons.
cmp is a struct of the form {T: _, x: T, y: T, less: bool}, where less should reflect x < y.
Example:
Sort([2, 3, 1], list.Ascending) Sort([{a: 2}, {a: 3}, {a: 1}], {x: {}, y: {}, less: x.a < y.a})
func SortStrings ¶ added in v0.1.0
SortStrings sorts a list of strings in increasing order.
func Take ¶ added in v0.0.10
Take reports the prefix of length n of list x, or x itself if n > len(x).
For instance:
Take([1, 2, 3, 4], 2)
results in
[1, 2]
func UniqueItems ¶
UniqueItems reports whether all elements in the list are unique.
Types ¶
This section is empty.