{"id":15010262,"url":"https://github.com/clojure/math.combinatorics","last_synced_at":"2025-05-15T05:07:38.342Z","repository":{"id":41283973,"uuid":"2124503","full_name":"clojure/math.combinatorics","owner":"clojure","description":"Efficient, functional algorithms for generating lazy sequences for common combinatorial functions","archived":false,"fork":false,"pushed_at":"2024-07-15T17:55:02.000Z","size":195,"stargazers_count":354,"open_issues_count":0,"forks_count":31,"subscribers_count":36,"default_branch":"master","last_synced_at":"2025-04-11T15:57:04.406Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":false,"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/clojure.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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}},"created_at":"2011-07-29T15:26:54.000Z","updated_at":"2025-03-14T10:57:10.000Z","dependencies_parsed_at":"2024-02-19T21:29:54.879Z","dependency_job_id":"c854ec61-e4bc-426f-8bf8-5d08dbe968c6","html_url":"https://github.com/clojure/math.combinatorics","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojure%2Fmath.combinatorics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojure%2Fmath.combinatorics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojure%2Fmath.combinatorics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clojure%2Fmath.combinatorics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clojure","download_url":"https://codeload.github.com/clojure/math.combinatorics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254276447,"owners_count":22043867,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-09-24T19:33:13.621Z","updated_at":"2025-05-15T05:07:33.332Z","avatar_url":"https://github.com/clojure.png","language":"Clojure","funding_links":[],"categories":["Clojure"],"sub_categories":[],"readme":"clojure.math.combinatorics\n========================================\n\nFormerly clojure.contrib.combinatorics.\n\nEfficient, functional algorithms for generating lazy\nsequences for common combinatorial functions.\n\nReleases and Dependency Information\n========================================\n\nLatest stable release: 0.3.0\n\n* [All Released Versions](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.clojure%22%20AND%20a%3A%22math.combinatorics%22)\n* [Development Snapshot Versions](https://oss.sonatype.org/index.html#nexus-search;gav~org.clojure~math.combinatorics~~~)\n\n[CLI/`deps.edn`](https://clojure.org/reference/deps_and_cli) dependency information:\n```clojure\norg.clojure/math.combinatorics {:mvn/version \"0.3.0\"}\n```\n\n[Leiningen](https://github.com/technomancy/leiningen) dependency information:\n\n```clojure\n[org.clojure/math.combinatorics \"0.3.0\"]\n```\n\n[Maven](https://maven.apache.org/) dependency information:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eorg.clojure\u003c/groupId\u003e\n  \u003cartifactId\u003emath.combinatorics\u003c/artifactId\u003e\n  \u003cversion\u003e0.3.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n*Note: If you are using Clojure 1.2 - 1.6, you will need math.combinatorics version 0.1.3.*\n\nExample Usage\n========================================\n\nThe following functions take sequential collections\n(such as lists and vectors) as inputs. If you want\nto call a function on a set, you must explicitly\ncall `seq` on the set first.\n\nAll functions return lazy sequences.\n\n```clojure\n(ns example.core\n  (:require [clojure.math.combinatorics :as combo]))\n\n; PERMUTATIONS\n; all the unique arrangements of items\n=\u003e (combo/permutations [1 2 3])\n([1 2 3] [1 3 2] [2 1 3] [2 3 1] [3 1 2] [3 2 1])\n\n; Note that permutations intelligently handles duplicate items\n=\u003e (combo/permutations [1 1 2])\n([1 1 2] [1 2 1] [2 1 1])\n\n; These functions are more efficient than calling count, nth, drop\n; on the underlying sequence\n=\u003e (combo/count-permutations [1 2 3])\n6\n=\u003e (combo/count-permutations [1 1 2])\n3\n=\u003e (combo/nth-permutation [1 2 3] 3)\n[2 3 1]\n=\u003e (combo/nth-permutation [1 1 2 2] 5)\n[2 2 1 1]\n=\u003e (combo/drop-permutations [1 2 3] 3)\n([2 3 1] [3 1 2] [3 2 1])\n\n; For a sortable collection of items, you can find out where it is\n; in the lexicographic sequence of permutations\n=\u003e (combo/permutation-index [\\a \\b \\a \\c \\a \\b])\n16\n=\u003e (combo/nth-permutation [\\a \\a \\a \\b \\b \\c] 16)\n[\\a \\b \\a \\c \\a \\b]\n\n\n; COMBINATIONS\n; all the unique ways of taking t different elements from items\n(combo/combinations [1 2 3] 2)\n;;=\u003e ((1 2) (1 3) (2 3))\n\n; Note that combinations intelligently handles duplicate items\n; treating the input list as a representation of a 'multiset'\n =\u003e (combo/combinations [1 1 1 2 2] 3)\n((1 1 1) (1 1 2) (1 2 2))\n\n; These functions are more efficient than calling count and nth\n; on the underlying sequence\n=\u003e (combo/count-combinations [1 1 1 2 2] 3)\n3\n=\u003e (combo/nth-combination [1 2 3 4 5] 2 5)\n[2 4]\n\n; Permuting all the combinations\n=\u003e (combo/permuted-combinations [1 2 3] 2)\n([1 2] [2 1] [1 3] [3 1] [2 3] [3 2])\n=\u003e (combo/permuted-combinations [1 2 2] 2)\n([1 2] [2 1] [2 2])))\n\n\n; SUBSETS\n; all the subsets of items\n=\u003e (combo/subsets [1 2 3])\n(() (1) (2) (3) (1 2) (1 3) (2 3) (1 2 3))\n\n; Note that subsets intelligently handles duplicate items\n; treating the input list as a representation of a 'multiset'\n=\u003e (combo/subsets [1 1 2])\n(() (1) (2) (1 1) (1 2) (1 1 2))\n\n; These functions are more efficient than calling count and nth\n; on the underlying sequence\n=\u003e (combo/count-subsets [1 1 2])\n6\n=\u003e (combo/nth-subset [1 1 2] 3)\n[1 1]\n\n; CARTESIAN PRODUCT\n; all the ways to take one item from each passed-in sequence\n=\u003e (combo/cartesian-product [1 2] [3 4])\n((1 3) (1 4) (2 3) (2 4))\n\n; SELECTIONS\n; all the ways to take n (possibly the same) items from the sequence of items\n=\u003e (combo/selections [1 2] 3)\n((1 1 1) (1 1 2) (1 2 1) (1 2 2) (2 1 1) (2 1 2) (2 2 1) (2 2 2))\n\n; PARTITIONS\n; all the partitions of items.\n=\u003e (combo/partitions [1 2 3])\n(([1 2 3])\n ([1 2] [3])\n ([1 3] [2])\n ([1] [2 3])\n ([1] [2] [3]))\n\n ; Note that partitions intelligently handles duplicate items\n=\u003e (combo/partitions [1 1 2])\n(([1 1 2])\n ([1 1] [2])\n ([1 2] [1])\n ([1] [1] [2]))\n\n ; You can also specify a min and max number of partitions\n(combo/partitions [1 1 2 2] :min 2 :max 3)\n(([1 1 2] [2])\n ([1 1] [2 2])\n ([1 1] [2] [2])\n ([1 2 2] [1])\n ([1 2] [1 2])\n ([1 2] [1] [2])\n ([1] [1] [2 2]))\n```\n\nRefer to docstrings in the `clojure.math.combinatorics` namespace for\nadditional documentation.\n\n[API Documentation](https://clojure.github.io/math.combinatorics/)\n\nDeveloper Information\n========================================\n\n* [GitHub project](https://github.com/clojure/math.combinatorics)\n* [Bug Tracker](https://clojure.atlassian.net/browse/MCOMB)\n* [Continuous Integration](https://github.com/clojure/math.combinatorics/actions/workflows/test.yml)\n\nChangelog\n========================================\n* Release 0.3.0 on 2024-02-19\n  * Update parent pom\n\n* Release 0.2.0 on 2023-03-18\n  * MCOMB-11 - Fix incorrect results, overflow in partitions-M\n\n* Release 0.1.6 on 2019-07-24\n  * Improved laziness characteristics of many functions\n  * Added `permuted-combinations`\n\n* Release 0.1.5 on 2019-04-07\n  * Removed deprecated annotation on lex-permutations, which was causing problems for clojurescript users.\n\n* Release 0.1.4 on 2017-01-06\n  * Support for clojurescript (tested with 1.9.293)\n  * Dropped support for Clojure 1.2 - 1.6\n\n* Release 0.1.3 on 2016-06-02\n  * Changed boxing to use Long/valueOf.\n\n* Release 0.1.2 on 2016-05-18\n  * Added explicit boxing to eliminate auto-boxing warnings.\n    No change in functionality or performance from previous release.\n\n* Release 0.1.1 on 2015-03-20\n  * Backwards compatibility with 1.2.0 and 1.2.1\n\n* Release 0.1.0 on 2015-03-17\n  * combinations and subsets now have special handling for duplicate items\n  * Added count-permutations, count-combinations, count-subsets,\n     nth-permutation, nth-combination, nth-subset\n     drop-permutations, permutation-index\n\n* Release 0.0.9 on 2015-03-16\n  * Exclude \"update\" function from core for compatibility with 1.7.\n\n* Release 0.0.8 on 2014-07-20\n  * Minor improvement of helper function used by permutations.\n\n* Release 0.0.7 on 2013-11-13\n  * Unchunk range in `subsets` to minimize memory usage.\n\n* Release 0.0.6 on 2013-10-31\n  * Removed use of mapv for backwards compat with older versions of Clojure.\n\n* Release 0.0.5 on 2013-10-31\n  * Added partitions function\n\n* Release 0.0.4 on 2013-03-26\n  * Moved comment after ns declaration\n\n* Release 0.0.3 on 2012-07-06\n  * Fixed bug with (selections [false] 3) returning nil\n  * Fixed test syntax for Clojure 1.4.0/1.5.0\n\n* Release 0.0.2 on 2011-10-24\n  * Deprecated lex-permutations (permutations is now intelligent)\n\n* Release 0.0.1 on 2011-09-29\n  * Initial release.\n  * Source-compatible with clojure.contrib.math, except for the name change.\n\nLicense\n========================================\n\nDistributed under the Eclipse Public License, the same as Clojure.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclojure%2Fmath.combinatorics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclojure%2Fmath.combinatorics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclojure%2Fmath.combinatorics/lists"}