{"id":15176447,"url":"https://github.com/joergen7/lib_combin","last_synced_at":"2025-10-26T11:31:34.013Z","repository":{"id":57516033,"uuid":"66351842","full_name":"joergen7/lib_combin","owner":"joergen7","description":"Basic combinatorics for Erlang lists.","archived":false,"fork":false,"pushed_at":"2017-05-02T06:20:34.000Z","size":40,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-31T18:56:50.595Z","etag":null,"topics":["combinatorics","erlang"],"latest_commit_sha":null,"homepage":"","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joergen7.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}},"created_at":"2016-08-23T09:11:18.000Z","updated_at":"2021-06-03T13:51:58.000Z","dependencies_parsed_at":"2022-08-28T16:50:28.334Z","dependency_job_id":null,"html_url":"https://github.com/joergen7/lib_combin","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joergen7%2Flib_combin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joergen7%2Flib_combin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joergen7%2Flib_combin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joergen7%2Flib_combin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joergen7","download_url":"https://codeload.github.com/joergen7/lib_combin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238319493,"owners_count":19452343,"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":["combinatorics","erlang"],"created_at":"2024-09-27T13:04:14.561Z","updated_at":"2025-10-26T11:31:33.710Z","avatar_url":"https://github.com/joergen7.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lib_combin\n###### Basic combinatorics for Erlang lists and maps.\n[![hex.pm](https://img.shields.io/hexpm/v/lib_combin.svg?style=flat-square)](https://hex.pm/packages/lib_combin)\n\nThis library provides basic combinatoric operations like permutation or combinations without replacement for the most common data structures in Erlang: lists and maps.\n\nThe [documentation](https://cuneiform-lang.org/man/lib_combin/index.html) of the `lib_combin` module's API is available online.\n\n## Usage\n\n### Adding lib_combin to a Project\n\n#### rebar3\n\nTo integrate `lib_combin` into a rebar3 managed project change the `deps` entry in your application's `rebar.config` file to include the tuple `{lib_combin, \"0.1.5\"}`.\n\n    {deps, [{lib_combin, \"0.1.5\"}]}.\n\n#### mix\n\n    {:lib_combin, \"~\u003e 0.1.5\"}\n\n### Examples\n\n#### Combinations without replacement\n\nTo enumerate all combinations (order does not matter) without replacement of length 2 by drawing from the list `[a, b, c]` we use the `cnr/2` function as follows:\n\n    lib_combin:cnr( 2, [a, b, c] ).\n    [[b,a],[c,a],[c,b]]\n\nTo enumerate all combinations (order does not matter) without replacement of any possible length by drawing from the list `[a, b, c]` we use the `cnr_all/1` function as follows:\n\n    lib_combin:cnr_all( [a, b, c] ).\n    [[],[a],[b],[c],[b,a],[c,a],[c,b],[c,b,a]]\n\n#### Variations and Permutations\n\nTo enumerate all variations (order matters) without replacement of length 2 by drawing from the list `[a, b, c]` we use the `vnr/2` function as follows:\n\n    lib_combin:vnr( 2, [a, b, c] ).\n    [[b,a],[c,a],[a,b],[c,b],[a,c],[b,c]]\n\nTo enumerate all permutations (order matters) without replacement from the list `[a, b, c]` we use the `pnr/1` function as follows:\n\n    lib_combin:pnr( [a, b, c] ).\n    [[c,b,a],[b,c,a],[c,a,b],[a,c,b],[b,a,c],[a,b,c]]\n\n#### Maps\n\nSay, we're leading a burger restaurant which serves burgers made up from a fixed palette of ingredients for bread, meat, and sauce. We can represent the ingredients as an Erlang map in the following way:\n\n    Ingredients = #{ sauce =\u003e [ketchup, mayo],\n                     bread =\u003e [sesame, plain],\n                     meat  =\u003e [beef, chicken, mutton] }.\n\nTo find out which burgers can appear on the menu, we use the function `permut_map/1` as follows:\n\n    lib_combin:permut_map( Ingredients ).\n    [#{bread =\u003e plain,meat =\u003e beef,sauce =\u003e ketchup},\n     #{bread =\u003e sesame,meat =\u003e beef,sauce =\u003e ketchup},\n     #{bread =\u003e plain,meat =\u003e chicken,sauce =\u003e ketchup},\n     #{bread =\u003e sesame,meat =\u003e chicken,sauce =\u003e ketchup},\n     #{bread =\u003e plain,meat =\u003e mutton,sauce =\u003e ketchup},\n     #{bread =\u003e sesame,meat =\u003e mutton,sauce =\u003e ketchup},\n     #{bread =\u003e plain,meat =\u003e beef,sauce =\u003e mayo},\n     #{bread =\u003e sesame,meat =\u003e beef,sauce =\u003e mayo},\n     #{bread =\u003e plain,meat =\u003e chicken,sauce =\u003e mayo},\n     #{bread =\u003e sesame,meat =\u003e chicken,sauce =\u003e mayo},\n     #{bread =\u003e plain,meat =\u003e mutton,sauce =\u003e mayo},\n     #{bread =\u003e sesame,meat =\u003e mutton,sauce =\u003e mayo}]\n\n#### Factorial\n\nThe library also contains an implementation of the factorial function.\n\n    lib_combin:fac( 4 ).\n    24\n\n## System Requirements\n\n- Erlang OTP 18.0 or higher\n- Rebar3 3.0.0 or higher\n\n## Resources\n\n- [joergen7/gen_pnet](https://github.com/joergen7/gen_pnet) A generic Petri net OTP behavior using `lib_combin` to enumerate transition firing modes.\n- [seantanly/elixir-combination](https://github.com/seantanly/elixir-combination). An alternative library for combinations and permutations in Elixir.\n\n## Authors\n\n- Jorgen Brandt (joergen7) [joergen.brandt@onlinehome.de](mailto:joergen.brandt@onlinehome.de)\n\n## License\n\n[Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoergen7%2Flib_combin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoergen7%2Flib_combin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoergen7%2Flib_combin/lists"}