I have released a library called kotlin-tree that ...
# feed
y
I have released a library called kotlin-tree that allows for declarative handling of multi-way tree data in Kotlin. 🎉 Our API lets you define and perform operations on tree data just like Kotlin’s Collection APIs (map, filter, fold, etc.). Example usage:
Copy code
val treeNode: TreeNode<Int> = nodeOf(
    1,
    listOf(
        nodeOf(11, listOf(leafOf(111), leafOf(112))),
        leafOf(12)
    )
)
treeNode.map { ele -> ele * 2 }
Beyond node content operation, kotlin-tree supports conversion between different tree data representations like Adjacency Models and Path Enumeration Models. If you are interested, feel free to explore our repository at: https://github.com/YuitoSato/kotlin-tree
👍 1
1
👏🏾 1
👏 5
j
Do you think you would add a DSL for trees and transform it into a multiplatform library? Something like:
Copy code
node("a") {
    node("b") {
        node("c")
    }
    node("d")
    node("f")
}
y
@Javier That’s a good idea. Thank you. I think I’ll give DSL-style implementation as the next development theme. Which platform in particular would you like to use for multiple platforms other than jvm? Android?
Supported DSL Style. Thank you for your idea. https://github.com/YuitoSato/kotlin-tree/releases/tag/1.5.0
j
Don’t worry 😉 I have a custom stdlib in which I added a tree some months ago which I could stop maintain if there is something there to replace it. As it is a common data structure, it should support all platforms IMO
y
Thank you. I seems to be hard to support multi platforms, but I’ll try it.
j
Same setup with less code indeed, the only thing you have to remember is to publish from a Mac machine, as it is the only which is able to build all targets
🙌 1
217 Views