From 523aea1e122f02cc1d01063a3bb93df31d03fee1 Mon Sep 17 00:00:00 2001 From: peefy Date: Fri, 27 Oct 2023 14:15:58 +0800 Subject: [PATCH] feat: add collectionutil module v0.0.1 Signed-off-by: peefy --- collectionutil/README.md | 23 +++++++++++++++++++++++ collectionutil/kcl.mod | 4 ++++ collectionutil/main.k | 4 ++++ 3 files changed, 31 insertions(+) create mode 100644 collectionutil/README.md create mode 100644 collectionutil/kcl.mod create mode 100644 collectionutil/main.k diff --git a/collectionutil/README.md b/collectionutil/README.md new file mode 100644 index 00000000..7c8b2d0a --- /dev/null +++ b/collectionutil/README.md @@ -0,0 +1,23 @@ +## Introduction + +`collectionutil` is a kcl module for list and config values + +## How to Use + ++ Add the dependency + +```shell +kpm add collectionutil +``` + ++ Write the kcl code + +```python +import collectionutil + +items = collectionutil.to_str_set(["aa", "aa", "bb"]) # ["aa", "bb"] +``` + +## Resource + +Code source and document is [here](https://github.com/kcl-lang/artifacthub/tree/main/collectionutil) diff --git a/collectionutil/kcl.mod b/collectionutil/kcl.mod new file mode 100644 index 00000000..0c32bb81 --- /dev/null +++ b/collectionutil/kcl.mod @@ -0,0 +1,4 @@ +[package] +name = "collectionutil" +version = "0.0.1" +description = "`collectionutil` is a kcl module for list and config values" diff --git a/collectionutil/main.k b/collectionutil/main.k new file mode 100644 index 00000000..2abd81c8 --- /dev/null +++ b/collectionutil/main.k @@ -0,0 +1,4 @@ + +to_str_set = lambda items: [str] { + [item for item in {item = None for item in items}] +}