はじめに 明けましておめでとうございます! 年末年始でKotlinで木構造を宣言的に扱うためのkotlin-treeというOSSを公開しました! KotlinのCollection APIのように木構造を処理することができます。楽! val treeNode: TreeNode<Int> = nodeOf( 1, mutableListOf( nodeOf( 11, mutableList( leafOf(111), leafOf(112) ) ), leafOf(12) ) ) // 1 // ├── 11 // │ ├── 111 // │ └── 112 // └── 12 treeNode.map { ele -> ele * 2 } // 2 // ├── 22 // │ ├── 222 // │ └── 224 // └── 24 以下作ったモチベーションをつらつら書きます。
![Kotlinで木構造を宣言的に扱うOSS kotlin-treeを公開しました](https://cdn-ak-scissors.b.st-hatena.com/image/square/40de0251fd2fce099afc163dd7b6f11dde027f0c/height=288;version=1;width=512/https%3A%2F%2Fres.cloudinary.com%2Fzenn%2Fimage%2Fupload%2Fs--L2yA22tJ--%2Fc_fit%252Cg_north_west%252Cl_text%3Anotosansjp-medium.otf_55%3AKotlin%2525E3%252581%2525A7%2525E6%25259C%2525A8%2525E6%2525A7%25258B%2525E9%252580%2525A0%2525E3%252582%252592%2525E5%2525AE%2525A3%2525E8%2525A8%252580%2525E7%25259A%252584%2525E3%252581%2525AB%2525E6%252589%2525B1%2525E3%252581%252586OSS%252520kotlin-tree%2525E3%252582%252592%2525E5%252585%2525AC%2525E9%252596%25258B%2525E3%252581%252597%2525E3%252581%2525BE%2525E3%252581%252597%2525E3%252581%25259F%252Cw_1010%252Cx_90%252Cy_100%2Fg_south_west%252Cl_text%3Anotosansjp-medium.otf_37%3AYuito%252520Sato%252Cx_203%252Cy_98%2Fg_south_west%252Ch_90%252Cl_fetch%3AaHR0cHM6Ly9zdG9yYWdlLmdvb2dsZWFwaXMuY29tL3plbm4tdXNlci11cGxvYWQvYXZhdGFyL2Q5NWIwZmE1YjUuanBlZw%3D%3D%252Cr_max%252Cw_90%252Cx_87%252Cy_72%2Fog-base.png)