{"id":15069186,"url":"https://github.com/michaelbull/kotlin-itertools","last_synced_at":"2026-03-05T02:02:50.834Z","repository":{"id":225731810,"uuid":"766329179","full_name":"michaelbull/kotlin-itertools","owner":"michaelbull","description":"Multiplatform combinatoric sequences for Kotlin, inspired by python-itertools.","archived":false,"fork":false,"pushed_at":"2025-12-25T03:03:17.000Z","size":186,"stargazers_count":17,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-26T16:07:10.936Z","etag":null,"topics":["android","functional","functional-programming","ios","iterator","js","jvm","kotlin","kotlin-multiplatform","linux","python-itertools","sequence"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michaelbull.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-03-03T00:30:17.000Z","updated_at":"2025-12-25T03:03:20.000Z","dependencies_parsed_at":"2024-10-13T03:41:22.768Z","dependency_job_id":"a793c7ce-4ae7-439e-82e0-d34375dd4164","html_url":"https://github.com/michaelbull/kotlin-itertools","commit_stats":null,"previous_names":["michaelbull/kotlin-itertools"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/michaelbull/kotlin-itertools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelbull%2Fkotlin-itertools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelbull%2Fkotlin-itertools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelbull%2Fkotlin-itertools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelbull%2Fkotlin-itertools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michaelbull","download_url":"https://codeload.github.com/michaelbull/kotlin-itertools/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelbull%2Fkotlin-itertools/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30106146,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T01:39:18.192Z","status":"online","status_checked_at":"2026-03-05T02:00:06.710Z","response_time":93,"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":["android","functional","functional-programming","ios","iterator","js","jvm","kotlin","kotlin-multiplatform","linux","python-itertools","sequence"],"created_at":"2024-09-25T01:40:55.570Z","updated_at":"2026-03-05T02:02:50.823Z","avatar_url":"https://github.com/michaelbull.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kotlin-itertools\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.michael-bull.kotlin-itertools/kotlin-itertools.svg)](https://search.maven.org/search?q=g:com.michael-bull.kotlin-itertools)\n[![CI](https://github.com/michaelbull/kotlin-itertools/actions/workflows/ci.yaml/badge.svg)](https://github.com/michaelbull/kotlin-itertools/actions/workflows/ci.yaml)\n[![License](https://img.shields.io/github/license/michaelbull/kotlin-itertools.svg)](https://github.com/michaelbull/kotlin-itertools/blob/master/LICENSE)\n\n![badge][badge-android]\n![badge][badge-jvm]\n![badge][badge-js]\n![badge][badge-nodejs]\n![badge][badge-linux]\n![badge][badge-windows]\n![badge][badge-wasm]\n![badge][badge-ios]\n![badge][badge-mac]\n![badge][badge-tvos]\n![badge][badge-watchos]\n![badge][badge-js-ir]\n![badge][badge-android-native]\n![badge][badge-apple-silicon]\n\nMultiplatform combinatoric sequences for Kotlin, inspired by [python-itertools][python-itertools].\n\nInitially built as part of my solutions for [Advent of Code 2023][advent-2023].\n\n## Installation\n\n```groovy\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    implementation(\"com.michael-bull.kotlin-itertools:kotlin-itertools:1.0.4\")\n}\n```\n\n## Usage\n\n### Combinations\n\nReturns a sequence that yields `length`-sized combinations from this list.\n\nThe combination tuples are emitted in lexicographic order according to the order of this list.\n\n```kotlin\nfun \u003cT\u003e List\u003cT\u003e.combinations(length: Int = size): Sequence\u003cList\u003cT\u003e\u003e\n\nfun \u003cT\u003e List\u003cT\u003e.pairCombinations(): Sequence\u003cPair\u003cT, T\u003e\u003e\n\nfun \u003cT\u003e List\u003cT\u003e.tripleCombinations(): Sequence\u003cTriple\u003cT, T, T\u003e\u003e\n```\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eExamples\u003c/strong\u003e\u003c/summary\u003e\n\n```kotlin\nimport com.github.michaelbull.itertools.combinations\nimport com.github.michaelbull.itertools.pairCombinations\nimport com.github.michaelbull.itertools.tripleCombinations\n\n// [[A, B], [A, C], [A, D], [B, C], [B, D], [C, D]]\nfun example1(): List\u003cList\u003cChar\u003e\u003e {\n    return \"ABCD\".toList()\n        .combinations(length = 2)\n        .toList()\n}\n\n// [(A, B), (A, D), (A, C), (B, D), (B, C), (D, C)]\nfun example2(): List\u003cPair\u003cChar, Char\u003e\u003e {\n    return \"ABDC\".toList()\n        .pairCombinations()\n        .toList()\n}\n\n// [(0, 1, 2), (0, 1, 3), (0, 2, 3), (1, 2, 3)]\nfun example3(): List\u003cTriple\u003cInt, Int, Int\u003e\u003e {\n    return (0..3).toList()\n        .tripleCombinations()\n        .toList()\n}\n```\n\n\u003c/details\u003e\n\n### Permutations\n\nReturns a sequence that yields `length`-sized permutations from this list.\n\nThe permutation tuples are emitted in lexicographic order according to the order of this list.\n\n```kotlin\nfun \u003cT\u003e List\u003cT\u003e.permutations(length: Int = size): Sequence\u003cList\u003cT\u003e\u003e\n\nfun \u003cT\u003e List\u003cT\u003e.pairPermutations(): Sequence\u003cPair\u003cT, T\u003e\u003e\n\nfun \u003cT\u003e List\u003cT\u003e.triplePermutations(): Sequence\u003cTriple\u003cT, T, T\u003e\u003e\n```\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eExamples\u003c/strong\u003e\u003c/summary\u003e\n\n```kotlin\nimport com.github.michaelbull.itertools.permutations\nimport com.github.michaelbull.itertools.pairPermutations\nimport com.github.michaelbull.itertools.triplePermutations\n\n// [[A, B], [A, C], [A, D], [B, A], [B, C], [B, D], [C, A], [C, B], [C, D], [D, A], [D, B], [D, C]]\nfun example1(): List\u003cList\u003cChar\u003e\u003e {\n    return \"ABCD\".toList()\n        .permutations(length = 2)\n        .toList()\n}\n\n// [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)]\nfun example2(): List\u003cPair\u003cInt, Int\u003e\u003e {\n    return (0..2).toList()\n        .pairPermutations()\n        .toList()\n}\n\n// [(0, 1, 2), (0, 2, 1), (1, 0, 2), (1, 2, 0), (2, 0, 1), (2, 1, 0)]\nfun example3(): List\u003cTriple\u003cInt, Int, Int\u003e\u003e {\n    return (0..2).toList()\n        .triplePermutations()\n        .toList()\n}\n```\n\n\u003c/details\u003e\n\n### Cartesian Product\n\nReturns a sequence that yields the Cartesian product of the input iterables/lists.\n\nThe product tuples are emitted in lexicographic order according to the order of this iterable/list.\n\n```kotlin\nfun \u003cA, B\u003e Iterable\u003cA\u003e.product(other: Iterable\u003cB\u003e): Sequence\u003cPair\u003cA, B\u003e\u003e\nfun \u003cA, B, C\u003e Iterable\u003cA\u003e.product(first: Iterable\u003cB\u003e, second: Iterable\u003cC\u003e): Sequence\u003cTriple\u003cA, B, C\u003e\u003e\n\nfun \u003cA, B\u003e Pair\u003cIterable\u003cA\u003e, Iterable\u003cB\u003e\u003e.product(): Sequence\u003cPair\u003cA, B\u003e\u003e\nfun \u003cA, B, C\u003e Triple\u003cIterable\u003cA\u003e, Iterable\u003cB\u003e, Iterable\u003cC\u003e\u003e.product(): Sequence\u003cTriple\u003cA, B, C\u003e\u003e\n\nfun \u003cT\u003e List\u003cList\u003cT\u003e\u003e.product(): Sequence\u003cList\u003cT\u003e\u003e\n```\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eExamples\u003c/strong\u003e\u003c/summary\u003e\n\n```kotlin\nimport com.github.michaelbull.itertools.product\n\n// [(A, x), (A, y), (B, x), (B, y), (C, x), (C, y), (D, x), (D, y)]\nfun example1(): List\u003cPair\u003cChar, Char\u003e\u003e {\n    val a = \"ABCD\".toList()\n    val b = \"xy\".toList()\n    return a.product(b).toList()\n}\n\n// [(A, C, E), (A, C, F), (A, D, E), (A, D, F), (B, C, E), (B, C, F), (B, D, E), (B, D, F)]\nfun example2(): List\u003cTriple\u003cChar, Char, Char\u003e\u003e {\n    val a = \"AB\".toList()\n    val b = \"CD\".toList()\n    val c = \"EF\".toList()\n\n    return Triple(a, b, c)\n        .product()\n        .toList()\n}\n\n// [[A, x], [A, y], [B, x], [B, y], [C, x], [C, y], [D, x], [D, y]]\nfun example3(): List\u003cList\u003cChar\u003e\u003e {\n    val a = \"ABCD\".toList()\n    val b = \"xy\".toList()\n\n    return listOf(a, b)\n        .product()\n        .toList()\n}\n```\n\u003c/details\u003e\n\n## Contributing\n\nBug reports and pull requests are welcome on [GitHub][github].\n\n## License\n\nThis project is available under the terms of the ISC license. See the\n[`LICENSE`](LICENSE) file for the copyright information and licensing terms.\n\n[python-itertools]: https://docs.python.org/3/library/itertools.html\n[advent-2023]: https://github.com/michaelbull/advent-2023\n[github]: https://github.com/michaelbull/kotlin-itertools\n\n[badge-android]: http://img.shields.io/badge/-android-6EDB8D.svg?style=flat\n[badge-android-native]: http://img.shields.io/badge/support-[AndroidNative]-6EDB8D.svg?style=flat\n[badge-jvm]: http://img.shields.io/badge/-jvm-DB413D.svg?style=flat\n[badge-js]: http://img.shields.io/badge/-js-F8DB5D.svg?style=flat\n[badge-js-ir]: https://img.shields.io/badge/support-[IR]-AAC4E0.svg?style=flat\n[badge-nodejs]: https://img.shields.io/badge/-nodejs-68a063.svg?style=flat\n[badge-linux]: http://img.shields.io/badge/-linux-2D3F6C.svg?style=flat\n[badge-windows]: http://img.shields.io/badge/-windows-4D76CD.svg?style=flat\n[badge-wasm]: https://img.shields.io/badge/-wasm-624FE8.svg?style=flat\n[badge-apple-silicon]: http://img.shields.io/badge/support-[AppleSilicon]-43BBFF.svg?style=flat\n[badge-ios]: http://img.shields.io/badge/-ios-CDCDCD.svg?style=flat\n[badge-mac]: http://img.shields.io/badge/-macos-111111.svg?style=flat\n[badge-watchos]: http://img.shields.io/badge/-watchos-C0C0C0.svg?style=flat\n[badge-tvos]: http://img.shields.io/badge/-tvos-808080.svg?style=flat\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelbull%2Fkotlin-itertools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaelbull%2Fkotlin-itertools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelbull%2Fkotlin-itertools/lists"}