Dart Documentationcombinators

combinators library

Properties

final Enumeration<bool> bools #

final Enumeration<bool> bools = _mkBools()

final Enumeration<int> ints #

final Enumeration<int> ints = _mkInts()

final Enumeration<int> nats #

final Enumeration<int> nats = _mkNats()

final Enumeration<Rational> positiveRationals #

final Enumeration<Rational> positiveRationals = _mkPositiveRationals()

final Enumeration<Rational> rationals #

final Enumeration<Rational> rationals = _mkRationals()

final Enumeration<String> strings #

final Enumeration<String> strings = _mkStrings()

Functions

Enumeration<Map> mapsOf(Enumeration keys, Enumeration values) #

Enumeration<Map> mapsOf(Enumeration keys, Enumeration values) {
 // bijection from lists of (nat x value) to maps of (key x value)
 bij(assocs) {
   var res = new Map();
   int sum = -1;
   for (final assoc in assocs) {
     sum += 1 + assoc.fst;
     res[keys[sum]] = assoc.snd;
   }
   return res;
 }
 return listsOf(nats * values).map(bij);

}

Enumeration<Set> setsOf(Enumeration enumeration) #

Enumeration<Set> setsOf(Enumeration enumeration) {
 // bijection from lists of nats to sets of values
 bij(list) {
   var res = new Set();
   int sum = -1;
   for (final x in list) {
     sum += 1 + x;
     res.add(enumeration[sum]);
   }
   return res;
 }
 return listsOf(nats).map(bij);
}

Enumeration<List> listsOf(Enumeration enumeration) #

Enumeration<List> listsOf(Enumeration enumeration) {
 final nils = singleton(_nil());
 consesOf(e) => singleton(_cons).apply(enumeration).apply(e);
 final llists = fix((e) => (nils + consesOf(e).pay()));
 return llists.map((ll) => ll.toList());
}