Skip to content

Commit

Permalink
feat: add list flattern functions for the collectionutil module
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Mar 18, 2024
1 parent 1740c71 commit 64eee1f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion collectionutil/kcl.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[package]
name = "collectionutil"
version = "0.0.1"
version = "0.0.2"
description = "`collectionutil` is a kcl module for list and config values"

Empty file added collectionutil/kcl.mod.lock
Empty file.
4 changes: 4 additions & 0 deletions collectionutil/main.k
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
to_str_set = lambda items: [str] {
[item for item in {item = None for item in items}]
}

list_flattern = lambda items: [any] -> [any] {
sum(items, [])
}
7 changes: 7 additions & 0 deletions collectionutil/main_test.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
test_to_str_set = lambda {
assert to_str_set(["a", "a", "b"]) == ["a", "b"]
}

test_list_flattern = lambda {
assert list_flattern([[1, 2], [3, 4]]) == [1, 2, 3, 4]
}

0 comments on commit 64eee1f

Please sign in to comment.