Welcome to trotter, a Dart library that simplifies working with structures commonly encountered in combinatorics such as combinations and permutations.
Trotter gives the developer access to pseusolists that "contain" all arrangements of objects taken from a specified set.
For example, the following programme creates a pseudolist "containing" all the 3permutations of the first five letters and reports some information.
import "package:trotter/trotter.dart";
void main() {
var perms3 = new Permutations(3, "abcde".split(""));
print("There are ${perms3.length} 3permutations of the objects in ${perms3.elements}.");
print("The first 3permutation is ${perms3[0]}.");
print("The first three 3permutations are: ${perms3.range(0, 3)}.");
}
There are 60 3permutations of the objects in [a, b, c, d, e].
The first 3permutation is [a, b, c].
The first three 3permutations are: [[a, b, c], [a, c, b], [c, a, b]].
The classes defined in trotter technically provide a mapping between integers and the structures contained within a pseudolist; they do not store the structures in memory. This allows us to work with pseudolists "containing" very large numbers of arrangements with very little overhead. For example, consider the following programme that works with a very large list of permutations.
import "package:trotter/trotter.dart";
void main() {
var perms10 = new Permutations(10, "abcdefghijklmno".split(""));
print("There are ${perms10.length} 10permutations of the first 15 letters.");
print("The 10,000,000,000th permutation 'stored' in perms10 is ${perms10[9999999999]}.");
}
There are 10897286400 10permutations of the first 15 letters.
The 10,000,000,000th permutation 'stored' in perms10 is [m, k, j, d, e, g, f, i, c, n].
Trotter contains four classes for working with some items taken from a list.
Permutations
: Order is important; items cannot be chosen more than once.Combinations
: Order is not important; items cannot be chosen more than once.Amalgams
: Order is important; items can be chosen more than once.Selections
: Order is not important; items can be chosen more than once.All of these classes can be used similarly to the way Permutations
is used in the examples above.
Further, a class Subsets
exists to create a pseudolist of all the subsets of objects stored in a list. For example, the following programme creates a pseudolist containing all the subsets (combinations of any size) created from the first five letters.
import "package:trotter/trotter.dart";
void main() {
var subs = new Subsets("abcde".split(""));
print("There are ${subs.length} subsets of the objects in ${subs.elements}.");
print("The first subset is the empty set: ${subs[0]}.");
print("The tenth subset in subs contains the elements ${subs[9]}.");
}
There are 32 subsets of the objects in [a, b, c, d, e].
The first subset is the empty set: [].
The tenth subset in subs contains the elements [a, d].
First Dart release: support for classes:
Improved the documentation.
Add this to your package's pubspec.yaml file:
dependencies:
trotter: ^0.5.1
You can install packages from the command line:
with pub:
$ pub get
Alternatively, your editor might support pub get
.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:trotter/trotter.dart';
Version  Uploaded  Documentation  Archive 

1.0.2  Aug 10, 2018  
1.0.1  Aug 8, 2018  
1.0.0  Aug 3, 2018  
0.9.5  May 7, 2018  
0.9.1  Dec 10, 2017  
0.9.0  Dec 7, 2017  
0.8.5  Jan 13, 2017  
0.8.1  Feb 10, 2016  
0.8.0  Feb 8, 2016  
0.5.2  Nov 26, 2014 
Popularity:
Describes how popular the package is relative to other packages.
[more]



Health:
Code health derived from static analysis.
[more]



Maintenance:
Reflects how tidy and uptodate the package is.
[more]



Overall:
Weighted score of the above.
[more]



This package version is not analyzed, because it is more than two years old. Check the latest stable version for its analysis.
Package  Constraint  Resolved  Available 

Direct dependencies  
Dart SDK  1.6.0 