{"id":15041012,"url":"https://github.com/yahyatinani/y","last_synced_at":"2026-06-10T17:31:30.093Z","repository":{"id":39598108,"uuid":"290997023","full_name":"yahyatinani/y","owner":"yahyatinani","description":"'y' is a library that aims to provide useful data structures and utility functions.","archived":false,"fork":false,"pushed_at":"2023-06-29T07:39:55.000Z","size":1680,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-01T01:02:10.184Z","etag":null,"topics":["data-structures","immutable-collections","kmp","kotlin","kotlin-multiplatform","lists","maps","vectors"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yahyatinani.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-08-28T08:45:11.000Z","updated_at":"2023-01-19T11:24:26.000Z","dependencies_parsed_at":"2024-01-16T12:49:13.799Z","dependency_job_id":"d360e6b9-2443-4029-9ed5-a35d32a1ff42","html_url":"https://github.com/yahyatinani/y","commit_stats":null,"previous_names":["whyrising/y"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/yahyatinani/y","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahyatinani%2Fy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahyatinani%2Fy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahyatinani%2Fy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahyatinani%2Fy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yahyatinani","download_url":"https://codeload.github.com/yahyatinani/y/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahyatinani%2Fy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34163253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-structures","immutable-collections","kmp","kotlin","kotlin-multiplatform","lists","maps","vectors"],"created_at":"2024-09-24T20:45:24.173Z","updated_at":"2026-06-10T17:31:30.070Z","avatar_url":"https://github.com/yahyatinani.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Y](docs/art/logo-with-text.png)\n========\n\n[![build](https://github.com/yahyatinani/y/actions/workflows/main.yml/badge.svg)](https://github.com/yahyatinani/y/actions/workflows/main.yml) ![Sonatype Nexus (Releases)](https://img.shields.io/nexus/r/io.github.yahyatinani.y/y-core?server=https%3A%2F%2Fs01.oss.sonatype.org%2F\u0026label=latest%20release\u0026color=blue) ![GitHub](https://img.shields.io/github/license/yahyatinani/y)\n ![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/io.github.yahyatinani.y/y-core?server=https%3A%2F%2Fs01.oss.sonatype.org%2F\u0026label=latest%20snapshot)\n [![codecov](https://codecov.io/gh/yahyatinani/y/branch/main/graph/badge.svg?token=O7NV8M4TTP)](https://codecov.io/gh/yahyatinani/y)\n\n`y` is a Kotlin multiplatform library that aims to port and provide effective\nconcepts inspired by other languages or libraries.\n\n## Modules:\n\n### y-core:\n\nThis module provides core data structures and utility functions.\n\n- ##### Data structures:\n\n    - List:\n\n      ```kotlin\n      val list1 = l\u003cInt\u003e(1,2,3) // (1 2 3)\n      val empty = l\u003cInt\u003e() // ()\n          \n      // From Kotlin's List\u003cE\u003e to PersistentList\u003cE\u003e\n      val list2 = listOf\u003cInt\u003e(1, 2, 3).toPlist() // (1 2 3)\n      ```\n\n      To add an item to a list, use `conj(e)`, it puts the item at the front\n      of the list and returns a new list.\n\n      ```kotlin\n      l\u003cInt\u003e(1,2,3).conj(4) // (4 1 2 3)\n      ```\n\n      To get the size of a list:\n\n      ```kotlin\n      l\u003cInt\u003e(1,2,3).count // 3\n      ```\n\n    - Vector:\n\n        ```kotlin\n      val vec1 = v\u003cInt\u003e(1, 2, 3) // [1 2 3]\n        val empty = v\u003cInt\u003e() // []\n            \n        // From Kotlin's List\u003cE\u003e to PersistentVector\u003cE\u003e\n        val vec2 = listOf\u003cInt\u003e(1, 2, 3).toPvector() // [1 2 3]\n      ```\n\n      To add an item to a vector, use `conj(e)`, it puts the item at the end\n      of the vector and returns a new vector.\n\n      ```kotlin\n      v\u003cInt\u003e(1, 2, 3).conj(4) // [1 2 3 4]\n      ```\n\n      To get the size of a vector:\n\n      ```kotlin\n      v\u003cInt\u003e(1, 2, 3).count // 3\n      ```\n\n      To get an item by index, you can use `get(index)` operator\n      or `nth(index)`/`nth(index, def)`\n\n      ```kotlin\n      v\u003cInt\u003e(1, 2, 3)[1] // 2\n      v\u003cInt\u003e(1, 2, 3).nth(2) // 3\n      v\u003cInt\u003e(1, 2, 3).nth(5, -1) // -1\n      ```\n\n      To get the items in reverse order as a sequence, use `reverse()`\n\n      ```kotlin\n      v\u003cInt\u003e(1, 2, 3).reverse() // (3 2 1)\n      ```\n\n    - PersistentArrayMap:\n\n      This map should be only used when you have very small maps and want to\n      maintain key order, since it is just an array of `[key,val..key,val]`.\n      Subsequent `assoc-ing` will eventually return a `PersistentHashMap`.\n\n        ```kotlin\n        val map1 = m\u003cString, Int\u003e(\"1\" to 1, \"2\" to 2) // {\"1\" 1, \"2\" 2}\n              \n        //From Kotlin's Map\u003cK,V\u003e to PersistentArrayMap\u003cK,V\u003e\n        val map2 = mapOf\u003cString, Int\u003e(\"1\" to 1, \"2\" to 2).toPArrayMap() // {\"1\" 1, \"2\" 2}\n        ```\n\n    - PersistentHashMap:\n\n      This map requires keys that correctly support hashCode and equals.\n\n        ```kotlin\n        val map1 = hashMap\u003cString, Int\u003e(\"1\" to 1, \"2\" to 2) // {\"1\" 1, \"2\" 2}\n            \n        //From Kotlin's Map\u003cK,V\u003e to PersistentHashMap\u003cK,V\u003e\n        val map2 = mapOf\u003cString, Int\u003e(\"1\" to 1, \"2\" to 2).toPhashMap() // {\"1\" 1, \"2\" 2}\n        ```\n\n    - PersistentHashSet:\n\n      ```kotlin\n      val set1 = hs\u003cInt\u003e(1, 2, 2, 3, 3) // #{1 2 3}\n          \n      //From Kotlin's Set\u003cE\u003e to PersistentHashSet\u003cE\u003e\n      val set2 = setOf\u003cInt\u003e(1, 2, 2, 3 ,3).toPhashSet() // #{1 2 3}\n      ```\n\n    - Sequence:\n\n      All collections support a member function `seq()` that return a\n      sequence of type `ISeq\u003cE\u003e` that can walk the entire collection. A\n      sequance provides three key member functions:\n\n        - `first()` : return the first element in the sequence.\n        - `rest()` : returns all of the rest elements of the sequence that\n          came after first element, as a sequence.\n        - `cons(element)` : always adds to the front of the sequence and\n          returns a sequence.\n\n    - ###### Keywords (WIP, only on JVM for now):\n\n      Keywords are identifiers that provide very fast equality tests, and they\n      have a string name. If you call toString() on a keyword it returns the\n      name prefixed by a ':' which is not part of the name.\n\n      ```kotlin\n      // To create a Keyword, use the utility function `k(name)`:\n      val keyword = k(\"a\") // :a\n      \n      // invoke(map, default = null) operator\n      val map = hashMap(\"a\" to 1)\n      val key = k(\"a\")\n      val default = k(\"none\")\n      key(map, default) // :none\n      ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyahyatinani%2Fy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyahyatinani%2Fy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyahyatinani%2Fy/lists"}