diff --git a/ext/lists.go b/ext/lists.go index 3eebe086..f4250294 100644 --- a/ext/lists.go +++ b/ext/lists.go @@ -49,15 +49,15 @@ var comparableTypes = []*cel.Type{ // Returns the distinct elements of a list. If the element type is not comparable // or the element types are not the same, the function will produce an error. // -// .distinct() -> -// T in {int, uint, double, bool, duration, timestamp, string, bytes} +// .distinct() -> +// T in {int, uint, double, bool, duration, timestamp, string, bytes} // // Examples: // -// [1, 2, 2, 3, 3, 3].distinct() // return [1, 2, 3] -// ["b", "c", "a"].sort() // return ["a", "b", "c"] -// [1, "b"].distinct() // error -// [[1, 2, 3]].distinct() // error +// [1, 2, 2, 3, 3, 3].distinct() // return [1, 2, 3] +// ["b", "c", "a"].sort() // return ["a", "b", "c"] +// [1, "b"].distinct() // error +// [[1, 2, 3]].distinct() // error // // # Range // @@ -65,11 +65,11 @@ var comparableTypes = []*cel.Type{ // // Returns a list of integers from 0 to n-1. // -// range() -> +// range() -> // // Examples: // -// range(5) -> [0, 1, 2, 3, 4] +// range(5) -> [0, 1, 2, 3, 4] // // ## Reverse // @@ -77,22 +77,22 @@ var comparableTypes = []*cel.Type{ // // Returns the elements of a list in reverse order. // -// .reverse() -> +// .reverse() -> // // Examples: // -// [5, 3, 1, 2].reverse() // return [2, 1, 3, 5] +// [5, 3, 1, 2].reverse() // return [2, 1, 3, 5] // // # Slice // // Returns a new sub-list using the indexes provided. // -// .slice(, ) -> +// .slice(, ) -> // // Examples: // -// [1,2,3,4].slice(1, 3) // return [2, 3] -// [1,2,3,4].slice(2, 4) // return [3 ,4] +// [1,2,3,4].slice(1, 3) // return [2, 3] +// [1,2,3,4].slice(2, 4) // return [3 ,4] // // # Flatten // @@ -100,8 +100,8 @@ var comparableTypes = []*cel.Type{ // If an optional depth is provided, the list is flattened to a the specificied level. // A negative depth value will result in an error. // -// .flatten() -> -// .flatten(, ) -> +// .flatten() -> +// .flatten(, ) -> // // Examples: // @@ -118,15 +118,15 @@ var comparableTypes = []*cel.Type{ // Sorts a list with comparable elements. If the element type is not comparable // or the element types are not the same, the function will produce an error. // -// .sort() -> -// T in {int, uint, double, bool, duration, timestamp, string, bytes} +// .sort() -> +// T in {int, uint, double, bool, duration, timestamp, string, bytes} // // Examples: // -// [3, 2, 1].sort() // return [1, 2, 3] -// ["b", "c", "a"].sort() // return ["a", "b", "c"] -// [1, "b"].sort() // error -// [[1, 2, 3]].sort() // error +// [3, 2, 1].sort() // return [1, 2, 3] +// ["b", "c", "a"].sort() // return ["a", "b", "c"] +// [1, "b"].sort() // error +// [[1, 2, 3]].sort() // error // // # SortBy // @@ -135,12 +135,12 @@ var comparableTypes = []*cel.Type{ // // Examples: // -// [ -// Player { name: "foo", score: 0 }, -// Player { name: "bar", score: -10 }, -// Player { name: "baz", score: 1000 }, -// ].sortBy(e, e.score).map(e, e.name) -// == ["bar", "foo", "baz"] +// [ +// Player { name: "foo", score: 0 }, +// Player { name: "bar", score: -10 }, +// Player { name: "baz", score: 1000 }, +// ].sortBy(e, e.score).map(e, e.name) +// == ["bar", "foo", "baz"] // // # SortByAssociatedKeys // @@ -150,12 +150,12 @@ var comparableTypes = []*cel.Type{ // another list of comparable elements. If the element type of the keys is not // comparable or the element types are not the same, the function will produce an error. // -// .sortByAssociatedKeys() -> -// U in {int, uint, double, bool, duration, timestamp, string, bytes} +// .sortByAssociatedKeys() -> +// U in {int, uint, double, bool, duration, timestamp, string, bytes} // // Examples: // -// ["foo", "bar", "baz"].sortByAssociatedKeys([3, 1, 2]) // return ["bar", "baz", "foo"] +// ["foo", "bar", "baz"].sortByAssociatedKeys([3, 1, 2]) // return ["bar", "baz", "foo"] func Lists(options ...ListsOption) cel.EnvOption { l := &listsLib{ @@ -499,11 +499,11 @@ func sortListByAssociatedKeys(list traits.Lister, keys traits.Lister) (ref.Val, // // into: // -// cel.bind( -// __sortBy_input__, -// myListExpr, -// __sortBy_input__.sortByAssociatedKeys(__sortBy_input__.map(e, -math.abs(e)) -// ) +// cel.bind( +// __sortBy_input__, +// myListExpr, +// __sortBy_input__.sortByAssociatedKeys(__sortBy_input__.map(e, -math.abs(e)) +// ) func sortByMacro(meh cel.MacroExprFactory, target ast.Expr, args []ast.Expr) (ast.Expr, *cel.Error) { varIdent := meh.NewIdent("__sortBy_input__") varName := varIdent.AsIdent()