go: cuelang.org/go/pkg/list Index | Files

package list

import "cuelang.org/go/pkg/list"

Package list contains functions for manipulating and examining lists.

Index

Package Files

list.go math.go

func Avg Uses

func Avg(xs []*internal.Decimal) (*internal.Decimal, error)

Avg returns the average value of a non empty list xs.

func Contains Uses

func Contains(a []cue.Value, v cue.Value) bool

Contains reports whether v is contained in a. The value must be a comparable value.

func Drop Uses

func Drop(x []cue.Value, n int) ([]cue.Value, error)

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 Uses

func FlattenN(xs cue.Value, depth int) ([]cue.Value, error)

FlattenN reports a flattend 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 Max Uses

func Max(xs []*internal.Decimal) (*internal.Decimal, error)

Max returns the maximum value of a non empty list xs.

func MaxItems Uses

func MaxItems(a []cue.Value, n int) bool

MaxItems reports whether a has at most n items.

func Min Uses

func Min(xs []*internal.Decimal) (*internal.Decimal, error)

Min returns the minimum value of a non empty list xs.

func MinItems Uses

func MinItems(a []cue.Value, n int) bool

MinItems reports whether a has at least n items.

func Product Uses

func Product(xs []*internal.Decimal) (*internal.Decimal, error)

Product returns the product of a non empty list xs.

func Range Uses

func Range(start, limit, step *internal.Decimal) ([]*internal.Decimal, error)

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 Slice Uses

func Slice(x []cue.Value, i, j int) ([]cue.Value, error)

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 Sum Uses

func Sum(xs []*internal.Decimal) (*internal.Decimal, error)

Sum returns the sum of a list non empty xs.

func Take Uses

func Take(x []cue.Value, n int) ([]cue.Value, error)

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 Uses

func UniqueItems(a []cue.Value) bool

UniqueItems reports whether all elements in the list are unique.

Package list imports 5 packages (graph). Updated 2019-12-11. Refresh now. Tools for package owners.