trotter 0.5.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • --

Introduction

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 pseuso-lists that "contain" all arrangements of objects taken from a specified set.

For example, the following programme creates a pseudo-list "containing" all the 3-permutations 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} 3-permutations of the objects in ${perms3.elements}.");
  print("The first 3-permutation is ${perms3[0]}.");
  print("The first three 3-permutations are: ${perms3.range(0, 3)}.");
}

Output

There are 60 3-permutations of the objects in [a, b, c, d, e].
The first 3-permutation is [a, b, c].
The first three 3-permutations 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 pseudo-list; they do not store the structures in memory. This allows us to work with pseudo-lists "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} 10-permutations of the first 15 letters.");
  print("The 10,000,000,000th permutation 'stored' in perms10 is ${perms10[9999999999]}.");
}

Output

There are 10897286400 10-permutations 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].

Classes

Trotter contains four classes for working with some items taken from a list. Their distinguishing properties can be summarised in the following table.

Order ImportantOrder Not Important
Repetition Not AllowedPermutationsCombinations
Repetition AllowedAmalgamsSelections

All of these classes can be used similarly to the way Permutations was used in the examples above.

Further, a class Subsets exists to create a pseudo-list of all the subsets of objects stored in a list. For example, the following programme creates a pseudo-list 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]}.");
}

Output

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].

0.5.0

First Dart release: support for classes:

  • Permutations
  • Combinations
  • Amalgams (permutations with replacement during arranging)
  • Selections (combinations with replacement during arranging)
  • Subsets

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  trotter: ^0.5.0

2. Install it

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.

3. Import it

Now in your Dart code, you can use:


import 'package:trotter/trotter.dart';
  
Version Uploaded Documentation Archive
1.0.2 Aug 10, 2018 Go to the documentation of trotter 1.0.2 Download trotter 1.0.2 archive
1.0.1 Aug 8, 2018 Go to the documentation of trotter 1.0.1 Download trotter 1.0.1 archive
1.0.0 Aug 3, 2018 Go to the documentation of trotter 1.0.0 Download trotter 1.0.0 archive
0.9.5 May 7, 2018 Go to the documentation of trotter 0.9.5 Download trotter 0.9.5 archive
0.9.1 Dec 10, 2017 Go to the documentation of trotter 0.9.1 Download trotter 0.9.1 archive
0.9.0 Dec 7, 2017 Go to the documentation of trotter 0.9.0 Download trotter 0.9.0 archive
0.8.5 Jan 13, 2017 Go to the documentation of trotter 0.8.5 Download trotter 0.8.5 archive
0.8.1 Feb 10, 2016 Go to the documentation of trotter 0.8.1 Download trotter 0.8.1 archive
0.8.0 Feb 8, 2016 Go to the documentation of trotter 0.8.0 Download trotter 0.8.0 archive
0.5.2 Nov 26, 2014 Go to the documentation of trotter 0.5.2 Download trotter 0.5.2 archive

All 12 versions...

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 up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
--
Learn more about scoring.

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK 1.6.0