Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/seantanly/elixir-combination
A simple combinatorics library providing combination and permutation.
https://github.com/seantanly/elixir-combination
elixir-library permutation
Last synced: 2 months ago
JSON representation
A simple combinatorics library providing combination and permutation.
- Host: GitHub
- URL: https://github.com/seantanly/elixir-combination
- Owner: seantanly
- License: mit
- Created: 2016-01-15T06:22:31.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-02-25T07:31:56.000Z (almost 7 years ago)
- Last Synced: 2024-10-29T08:40:54.254Z (2 months ago)
- Topics: elixir-library, permutation
- Language: Elixir
- Homepage:
- Size: 88.9 KB
- Stars: 34
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - Elixir library to generate combinations and permutations from Enumerable collection. (Algorithms and Data structures)
- fucking-awesome-elixir - combination - Elixir library to generate combinations and permutations from Enumerable collection. (Algorithms and Data structures)
- awesome-elixir - combination - Elixir library to generate combinations and permutations from Enumerable collection. (Algorithms and Data structures)
README
Combination
========
[![Build Status](https://travis-ci.org/seantanly/elixir-combination.svg?branch=master)](https://travis-ci.org/seantanly/elixir-combination)
[![Hex.pm Version](http://img.shields.io/hexpm/v/combination.svg?style=flat)](https://hex.pm/packages/combination)Elixir library to generate combinations and permutations from `Enumerable`.
See [Examples](#examples).
## Documentation
API documentation is available at [http://hexdocs.pm/combination](http://hexdocs.pm/combination)
## Adding Combination To Your Project
To use Combination with your projects, edit your `mix.exs` file and add it as a dependency:
```elixir
defp deps do
[
{:combination, "~> x.x.x"},
]
end
```## Examples
To generate combinations,
```elixir
iex> 1..3 |> Combination.combine(2)
[[3, 2], [3, 1], [2, 1]]```
To generate permutations,
```elixir
iex> 1..3 |> Combination.permutate
[[1, 2, 3], [2, 1, 3], [3, 1, 2], [1, 3, 2], [2, 3, 1], [3, 2, 1]]iex> 1..3 |> Combination.permutate(fn p -> Enum.at(p, 0) == 1 end)
[[1, 2, 3], [1, 3, 2]]```
## LICENSE
This software is licensed under [MIT License](LICENSE.md).