Skip to content

Commit 64eee1f

Browse files
committed
feat: add list flattern functions for the collectionutil module
Signed-off-by: peefy <[email protected]>
1 parent 1740c71 commit 64eee1f

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

collectionutil/kcl.mod

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[package]
22
name = "collectionutil"
3-
version = "0.0.1"
3+
version = "0.0.2"
44
description = "`collectionutil` is a kcl module for list and config values"
5+

collectionutil/kcl.mod.lock

Whitespace-only changes.

collectionutil/main.k

+4
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
to_str_set = lambda items: [str] {
33
[item for item in {item = None for item in items}]
44
}
5+
6+
list_flattern = lambda items: [any] -> [any] {
7+
sum(items, [])
8+
}

collectionutil/main_test.k

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
test_to_str_set = lambda {
2+
assert to_str_set(["a", "a", "b"]) == ["a", "b"]
3+
}
4+
5+
test_list_flattern = lambda {
6+
assert list_flattern([[1, 2], [3, 4]]) == [1, 2, 3, 4]
7+
}

0 commit comments

Comments
 (0)