bazel-skylib icon indicating copy to clipboard operation
bazel-skylib copied to clipboard

Provide a `lists` module.

Open cgrindel opened this issue 1 year ago • 0 comments

I have a Starlark lists module with several functions that make working with list values a little eaiser. I am willing to contribute it to bazel-skylib as the functionality seems generally useful.

Current functions:

  • compact: Given a list, return a new list having removed the items that equal None.
  • contains: It has two modes.
    • Given a list and a bool function (i.e., accepts a single parameter and returns a bool), it will return True if any of the items in the list satisfy the function.
    • Given a list and any other type, it will return True if any of the items equal the input.
  • find: Given a list and a bool function, it will return the item that satisfies the function.
  • flatten: Given a list that may contain items that are list values, it returns a list with all of the items flattened (i.e., no items in the result are an item of type list).

If the code owners are agreeable, I am willing to put up one or more PRs.

cgrindel avatar Jan 05 '23 20:01 cgrindel