#pragma once #include "phantom.hpp" #include /* We use size_t's for easy indexing. But we do not want to mix states and * inputs. We use phantom typing to "generate" distinguished types :). */ using state = phantom; using input = phantom; using output = phantom; using word = std::vector; // concattenation of words template std::vector concat(std::vector const & l, std::vector const & r){ std::vector ret(l.size() + r.size()); auto it = copy(begin(l), end(l), begin(ret)); copy(begin(r), end(r), it); return ret; } // extends all words in seqs by all input symbols. Used to generate *all* strings inline std::vector all_seqs(input min, input max, std::vector const & seqs){ std::vector ret((max.base() - min.base()) * seqs.size()); auto it = begin(ret); for(auto const & x : seqs){ for(input i = min; i < max; ++i){ it->resize(x.size() + 1); auto e = copy(x.begin(), x.end(), it->begin()); *e++ = i; it++; } } return ret; }