(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 46171, 1610] NotebookOptionsPosition[ 35962, 1263] NotebookOutlinePosition[ 38065, 1327] CellTagsIndexPosition[ 37559, 1312] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["StringTricks 1.20", "Title"], Cell["documentation notebook", "Subtitle"], Cell[TextData[{ "Eric Rowland\n", ButtonBox["http://math.tulane.edu/~erowland/packages.html", BaseStyle->"Hyperlink", ButtonData:>{ URL["http://math.tulane.edu/~erowland/packages.html"], None}] }], "Subsubtitle"], Cell[CellGroupData[{ Cell["Introduction", "Section"], Cell[TextData[{ "StringTricks is a collection of string manipulation tools. Most are string \ versions of core ", StyleBox["Mathematica", FontSlant->"Italic"], " list manipulation functions.\nThis introduction gets you started with some \ features of the package; the next section provides a complete list of package \ symbols along with their usage messages and further examples." }], "Text"], Cell[TextData[{ "To use StringTricks, first you will need to load the package by evaluating \ the following cell. (If you need help, see ", ButtonBox["loading a package", BaseStyle->"Hyperlink", ButtonData->{ URL["http://math.tulane.edu/~erowland/packages/loadingapackage.html"], None}, ButtonNote-> "http://math.tulane.edu/~erowland/packages/loadingapackage.html"], ".)" }], "Text"], Cell[BoxData[ RowBox[{"<<", "StringTricks`"}]], "Code"], Cell[CellGroupData[{ Cell["General string manipulation", "Subsection"], Cell[TextData[{ "StringTricks provides string analogues of ", StyleBox["ConstantArray", "Input"], ", ", StyleBox["Partition", "Input"], ", ", StyleBox["ReplaceRepeated", "Input"], ", ", StyleBox["Riffle", "Input"], ", ", StyleBox["RotateLeft", "Input"], ", ", StyleBox["RotateRight", "Input"], ", ", StyleBox["Tally", "Input"], ", and ", StyleBox["Tuples", "Input"], "." }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"StringPower", "[", RowBox[{"\"\\"", ",", "4"}], "]"}]], "Input"], Cell[BoxData["\<\"repeatrepeatrepeatrepeat\"\>"], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"StringPartition", "[", RowBox[{"%", ",", "6"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{"\<\"repeat\"\>", ",", "\<\"repeat\"\>", ",", "\<\"repeat\"\>", ",", "\<\"repeat\"\>"}], "}"}]], "Output"] }, Open ]], Cell["\<\ Generate the beginning of the Thue\[Dash]Morse sequence:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"StringReplaceRepeated", "[", RowBox[{"\"\<0\>\"", ",", RowBox[{"{", RowBox[{ RowBox[{"\"\<0\>\"", "\[Rule]", "\"\<01\>\""}], ",", RowBox[{"\"\<1\>\"", "\[Rule]", "\"\<10\>\""}]}], "}"}], ",", "6"}], "]"}]], "Input"], Cell[BoxData["\<\"\ 0110100110010110100101100110100110010110011010010110100110010110\"\>"], \ "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{"string", "=", "\"\<01020103010201040102010301020105\>\""}], "\n", RowBox[{"StringTake", "[", RowBox[{ RowBox[{"StringRiffle", "[", RowBox[{ RowBox[{"StringReplace", "[", RowBox[{"string", ",", RowBox[{"{", RowBox[{ RowBox[{"\"\<0\>\"", "\[Rule]", "\"\<1\>\""}], ",", RowBox[{"\"\<1\>\"", "\[Rule]", "\"\<2\>\""}], ",", RowBox[{"\"\<2\>\"", "\[Rule]", "\"\<3\>\""}], ",", RowBox[{"\"\<3\>\"", "\[Rule]", "\"\<4\>\""}], ",", RowBox[{"\"\<4\>\"", "\[Rule]", "\"\<5\>\""}], ",", RowBox[{"\"\<5\>\"", "\[Rule]", "\"\<6\>\""}]}], "}"}]}], "]"}], ",", "\"\<0\>\"", ",", RowBox[{"{", RowBox[{"1", ",", RowBox[{"-", "2"}], ",", "2"}], "}"}]}], "]"}], ",", "32"}], "]"}], "\n", RowBox[{"%", "\[Equal]", "%%"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Clear", "[", "string", "]"}], ";"}]}], "Input"], Cell[BoxData["\<\"01020103010201040102010301020105\"\>"], "Output"], Cell[BoxData["\<\"01020103010201040102010301020105\"\>"], "Output"], Cell[BoxData["True"], "Output"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Table", "[", RowBox[{ RowBox[{"StringRotateLeft", "[", RowBox[{"\"\\"", ",", "n"}], "]"}], ",", RowBox[{"{", RowBox[{"n", ",", "5"}], "}"}]}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{"\<\"bcdea\"\>", ",", "\<\"cdeab\"\>", ",", "\<\"deabc\"\>", ",", "\<\"eabcd\"\>", ",", "\<\"abcde\"\>"}], "}"}]], "Output"] }, Open ]], Cell["\<\ Find the number of occurrences of each letter in the Declaration of \ Independence:\ \>", "Text"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"StringTally", "[", RowBox[{"ToLowerCase", "[", RowBox[{"ExampleData", "[", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}], "]"}], "]"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"\<\"w\"\>", ",", "117"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"h\"\>", ",", "393"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"e\"\>", ",", "928"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"n\"\>", ",", "537"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\" \"\>", ",", "1440"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"i\"\>", ",", "495"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"t\"\>", ",", "686"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"c\"\>", ",", "204"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"o\"\>", ",", "578"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"u\"\>", ",", "218"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"r\"\>", ",", "489"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"s\"\>", ",", "519"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"f\"\>", ",", "190"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"m\"\>", ",", "178"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"a\"\>", ",", "540"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"v\"\>", ",", "76"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\",\"\>", ",", "110"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"b\"\>", ",", "105"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"y\"\>", ",", "91"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"p\"\>", ",", "151"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"l\"\>", ",", "278"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"d\"\>", ",", "266"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"g\"\>", ",", "150"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"q\"\>", ",", "6"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"'\"\>", ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"k\"\>", ",", "21"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\".\"\>", ",", "39"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"-\"\>", ",", "7"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"j\"\>", ",", "33"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"z\"\>", ",", "4"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\";\"\>", ",", "65"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"x\"\>", ",", "10"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\":\"\>", ",", "10"}], "}"}], ",", RowBox[{"{", RowBox[{"\<\"&\"\>", ",", "1"}], "}"}]}], "}"}]], "Output"] }, Open ]], Cell[TextData[{ StyleBox["StringTuples", "Input"], " gives all words of a given length on a given alphabet:" }], "Text"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"StringTuples", "[", RowBox[{ RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\"", ",", "\"\\""}], "}"}], ",", "3"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"{", RowBox[{"\<\"bbb\"\>", ",", "\<\"bba\"\>", ",", "\<\"bbt\"\>", ",", "\<\"bab\"\>", ",", "\<\"baa\"\>", ",", "\<\"bat\"\>", ",", "\<\"btb\"\>", ",", "\<\"bta\"\>", ",", "\<\"btt\"\>", ",", "\<\"abb\"\>", ",", "\<\"aba\"\>", ",", "\<\"abt\"\>", ",", "\<\"aab\"\>", ",", "\<\"aaa\"\>", ",", "\<\"aat\"\>", ",", "\<\"atb\"\>", ",", "\<\"ata\"\>", ",", "\<\"att\"\>", ",", "\<\"tbb\"\>", ",", "\<\"tba\"\>", ",", "\<\"tbt\"\>", ",", "\<\"tab\"\>", ",", "\<\"taa\"\>", ",", "\<\"tat\"\>", ",", "\<\"ttb\"\>", ",", "\<\"tta\"\>", ",", "\<\"ttt\"\>"}], "}"}]], "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["Parsing", "Subsection"], Cell[TextData[{ "Parsing nested expressions is a common string manipulation task. ", StyleBox["MatchPairs", "Input"], " finds matching pairs of nested infix operators." }], "Text"], Cell[BoxData[ RowBox[{ RowBox[{ "string", "=", "\"\
\""}], ";"}]], "Input"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"MatchPairs", "[", 
  RowBox[{"string", ",", 
   RowBox[{"{", 
    RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"17", ",", "21"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"25", ",", "27"}], "}"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"45", ",", "49"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"53", ",", "55"}], "}"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"5", ",", "9"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"63", ",", "65"}], "}"}]}], "}"}]}], "}"}]], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"Column", "[", 
  RowBox[{
   RowBox[{"(", 
    RowBox[{
     RowBox[{"StringTake", "[", 
      RowBox[{"string", ",", 
       RowBox[{"{", 
        RowBox[{
         RowBox[{"#1", "\[LeftDoubleBracket]", 
          RowBox[{"1", ",", "1"}], "\[RightDoubleBracket]"}], ",", 
         RowBox[{"#1", "\[LeftDoubleBracket]", 
          RowBox[{"2", ",", "2"}], "\[RightDoubleBracket]"}]}], "}"}]}], 
      "]"}], "&"}], ")"}], "/@", "%"}], "]"}]], "Input"],

Cell[BoxData[
 TagBox[GridBox[{
    {"\<\"start a end\"\>"},
    {"\<\"start b end\"\>"},
    {"\<\"start stuff start a end lots more stuff start b end junk! end\"\>"}
   },
   GridBoxAlignment->{"Columns" -> {{Left}}},
   GridBoxItemSize->{"Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}],
  "Column"]], "Output"]
}, Open  ]],

Cell[BoxData[
 RowBox[{"Clear", "[", "string", "]"}]], "Input"]
}, Closed]]
}, Open  ]],

Cell[CellGroupData[{

Cell["Package symbols", "Section"],

Cell[CellGroupData[{

Cell[TextData[{
 StyleBox["InExpression", "Input"],
 StyleBox[" (a variant of ", "Text",
  FontWeight->"Plain"],
 StyleBox["InString", "Input"],
 StyleBox[")", "Text",
  FontWeight->"Plain"]
}], "Subsubsection"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"?", "InExpression"}]], "Input"],

Cell[BoxData[
 StyleBox["\<\"InExpression[\*StyleBox[\\\"n\\\", \\\"TI\\\"]] gives the \
expression submitted as the \*StyleBox[\\\"n\\\", \\\"TI\\\"]th input line, \
wrapped in HoldComplete.\"\>", "MSG"]], "Print", "PrintUsage",
 CellTags->"Info3463241922-8143798"]
}, Open  ]],

Cell["Grab the last input expression:", "Text"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"2", "+", "2"}]], "Input"],

Cell[BoxData["4"], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"InExpression", "[", "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"HoldComplete", "[", 
  RowBox[{"2", "+", "2"}], "]"}]], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{
  OverscriptBox["a", 
   RowBox[{"n", "+", "1"}]], "+", 
  SuperscriptBox["a", 
   RowBox[{"n", "+", "2"}]], "+", 
  SubscriptBox["a", 
   RowBox[{"n", "+", "3"}]], "+", 
  UnderscriptBox["a", 
   RowBox[{"n", "+", "4"}]]}]], "Input"],

Cell[BoxData[
 RowBox[{
  SuperscriptBox["a", 
   RowBox[{"2", "+", "n"}]], "+", 
  OverscriptBox["a", 
   RowBox[{"1", "+", "n"}]], "+", 
  SubscriptBox["a", 
   RowBox[{"3", "+", "n"}]], "+", 
  UnderscriptBox["a", 
   RowBox[{"4", "+", "n"}]]}]], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"InExpression", "[", "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"HoldComplete", "[", 
  RowBox[{
   OverscriptBox["a", 
    RowBox[{"n", "+", "1"}]], "+", 
   SuperscriptBox["a", 
    RowBox[{"n", "+", "2"}]], "+", 
   SubscriptBox["a", 
    RowBox[{"n", "+", "3"}]], "+", 
   UnderscriptBox["a", 
    RowBox[{"n", "+", "4"}]]}], "]"}]], "Output"]
}, Open  ]]
}, Closed]],

Cell[CellGroupData[{

Cell[TextData[StyleBox["MatchPairs", "Input"]], "Subsubsection"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"?", "MatchPairs"}]], "Input"],

Cell[BoxData[
 StyleBox["\<\"MatchPairs[\*StyleBox[\\\"string\\\", \\\"TI\\\"], \
{\*StyleBox[\\\"openpattern\\\", \\\"TI\\\"], \
\*StyleBox[\\\"closepattern\\\", \\\"TI\\\"]}] gives the positions of each \
matching pair of matchfix operators in \*StyleBox[\\\"string\\\", \
\\\"TI\\\"].\\nMatchPairs[\*StyleBox[\\\"string\\\", \\\"TI\\\"], \*StyleBox[\
\\\"delimeter\\\", \\\"TI\\\"]] uses \*StyleBox[\\\"delimeter\\\", \
\\\"TI\\\"] for the opening and closing patterns.\"\>", "MSG"]], "Print", \
"PrintUsage",
 CellTags->"Info3463241934-3512694"]
}, Open  ]],

Cell["Extract each bracketed substring:", "Text"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"MatchPairs", "[", 
  RowBox[{"\"\<(()())\>\"", ",", 
   RowBox[{"{", 
    RowBox[{"\"\<(\>\"", ",", "\"\<)\>\""}], "}"}]}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"2", ",", "2"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"3", ",", "3"}], "}"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"4", ",", "4"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"5", ",", "5"}], "}"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"1", ",", "1"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"6", ",", "6"}], "}"}]}], "}"}]}], "}"}]], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{
  RowBox[{"(", 
   RowBox[{
    RowBox[{"StringTake", "[", 
     RowBox[{"\"\<(()())\>\"", ",", 
      RowBox[{"{", 
       RowBox[{
        RowBox[{"#1", "\[LeftDoubleBracket]", 
         RowBox[{"1", ",", "1"}], "\[RightDoubleBracket]"}], ",", 
        RowBox[{"#1", "\[LeftDoubleBracket]", 
         RowBox[{"2", ",", "2"}], "\[RightDoubleBracket]"}]}], "}"}]}], "]"}],
     "&"}], ")"}], "/@", "%"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{"\<\"()\"\>", ",", "\<\"()\"\>", ",", "\<\"(()())\"\>"}], 
  "}"}]], "Output"]
}, Open  ]],

Cell["A nonsyntactic string:", "Text"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"MatchPairs", "[", 
  RowBox[{"\"\<)))((()()(\>\"", ",", 
   RowBox[{"{", 
    RowBox[{"\"\<(\>\"", ",", "\"\<)\>\""}], "}"}]}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{
   RowBox[{"{", 
    RowBox[{"Null", ",", 
     RowBox[{"{", 
      RowBox[{"1", ",", "1"}], "}"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"Null", ",", 
     RowBox[{"{", 
      RowBox[{"2", ",", "2"}], "}"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"Null", ",", 
     RowBox[{"{", 
      RowBox[{"3", ",", "3"}], "}"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"6", ",", "6"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"7", ",", "7"}], "}"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"8", ",", "8"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"9", ",", "9"}], "}"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"4", ",", "4"}], "}"}], ",", "Null"}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"5", ",", "5"}], "}"}], ",", "Null"}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"10", ",", "10"}], "}"}], ",", "Null"}], "}"}]}], 
  "}"}]], "Output"]
}, Open  ]],

Cell["\<\
Switching the interpretation of the bracketing produces a syntactic string in \
this case:\
\>", "Text"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"MatchPairs", "[", 
  RowBox[{"\"\<)))((()()(\>\"", ",", 
   RowBox[{"{", 
    RowBox[{"\"\<)\>\"", ",", "\"\<(\>\""}], "}"}]}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"3", ",", "3"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"4", ",", "4"}], "}"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"2", ",", "2"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"5", ",", "5"}], "}"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"1", ",", "1"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"6", ",", "6"}], "}"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"7", ",", "7"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"8", ",", "8"}], "}"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"9", ",", "9"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"10", ",", "10"}], "}"}]}], "}"}]}], "}"}]], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"MatchPairs", "[", 
  RowBox[{"\"\\"", ",", "\"\<$\>\""}], 
  "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"5", ",", "5"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"16", ",", "16"}], "}"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"22", ",", "22"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"31", ",", "31"}], "}"}]}], "}"}]}], "}"}]], "Output"]
}, Open  ]]
}, Closed]],

Cell[CellGroupData[{

Cell[TextData[StyleBox["StringPartition", "Input"]], "Subsubsection"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"?", "StringPartition"}]], "Input"],

Cell[BoxData[
 StyleBox["\<\"StringPartition[\*StyleBox[\\\"string\\\", \\\"TI\\\"], \
\*StyleBox[\\\"n\\\", \\\"TI\\\"]] partitions \*StyleBox[\\\"string\\\", \
\\\"TI\\\"] into non\[Hyphen]overlapping substrings of length \
\*StyleBox[\\\"n\\\", \
\\\"TI\\\"].\\nStringPartition[\*StyleBox[\\\"string\\\", \\\"TI\\\"], \
\*StyleBox[\\\"n\\\", \\\"TI\\\"], \*StyleBox[\\\"d\\\", \\\"TI\\\"]] \
generates substrings with offset \*StyleBox[\\\"d\\\", \\\"TI\\\"].\"\>", 
  "MSG"]], "Print", "PrintUsage",
 CellTags->"Info3463241942-6239304"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"StringPartition", "[", 
  RowBox[{"\"\\"", ",", "2"}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{"\<\"ab\"\>", ",", "\<\"cd\"\>", ",", "\<\"ef\"\>", 
   ",", "\<\"gh\"\>"}], "}"}]], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"StringPartition", "[", 
  RowBox[{"\"\<12345678901\>\"", ",", "3", ",", "4"}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{"\<\"123\"\>", ",", "\<\"567\"\>", ",", "\<\"901\"\>"}], 
  "}"}]], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"StringPartition", "[", 
  RowBox[{"\"\<0110100110010110\>\"", ",", "4", ",", "1"}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{"\<\"0110\"\>", ",", "\<\"1101\"\>", ",", "\<\"1010\"\>", 
   ",", "\<\"0100\"\>", ",", "\<\"1001\"\>", ",", "\<\"0011\"\>", 
   ",", "\<\"0110\"\>", ",", "\<\"1100\"\>", ",", "\<\"1001\"\>", 
   ",", "\<\"0010\"\>", ",", "\<\"0101\"\>", ",", "\<\"1011\"\>", 
   ",", "\<\"0110\"\>"}], "}"}]], "Output"]
}, Open  ]]
}, Closed]],

Cell[CellGroupData[{

Cell[TextData[StyleBox["StringPower", "Input"]], "Subsubsection"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"?", "StringPower"}]], "Input"],

Cell[BoxData[
 StyleBox["\<\"StringPower[\*StyleBox[\\\"string\\\", \\\"TI\\\"], \
\*StyleBox[\\\"n\\\", \\\"TI\\\"]] generates a string of \
\*StyleBox[\\\"n\\\", \\\"TI\\\"] copies of \*StyleBox[\\\"string\\\", \\\"TI\
\\\"].\\nStringPower[\*StyleBox[\\\"string\\\", \\\"TI\\\"], \*StyleBox[\\\"n\
\\\", \\\"TI\\\"]/\*StyleBox[\\\"m\\\", \\\"TI\\\"]] generates a fractional \
power, if the length of \*StyleBox[\\\"string\\\", \\\"TI\\\"] is divisible \
by \*StyleBox[\\\"m\\\", \\\"TI\\\"].\"\>", "MSG"]], "Print", "PrintUsage",
 CellTags->"Info3463241947-8776518"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"StringPower", "[", 
  RowBox[{"\"\\"", ",", "10"}], "]"}]], "Input"],

Cell[BoxData["\<\"aaaaaaaaaa\"\>"], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"StringPower", "[", 
  RowBox[{"\"\<010\>\"", ",", "10"}], "]"}]], "Input"],

Cell[BoxData["\<\"010010010010010010010010010010\"\>"], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"Column", "[", 
  RowBox[{"Table", "[", 
   RowBox[{
    RowBox[{"StringPower", "[", 
     RowBox[{"\"\\"", ",", "n"}], "]"}], ",", 
    RowBox[{"{", 
     RowBox[{"n", ",", "0", ",", "4", ",", 
      FractionBox["1", "3"]}], "}"}]}], "]"}], "]"}]], "Input"],

Cell[BoxData[
 TagBox[GridBox[{
    {"\<\"\"\>"},
    {"\<\"ab\"\>"},
    {"\<\"abcd\"\>"},
    {"\<\"abcdef\"\>"},
    {"\<\"abcdefab\"\>"},
    {"\<\"abcdefabcd\"\>"},
    {"\<\"abcdefabcdef\"\>"},
    {"\<\"abcdefabcdefab\"\>"},
    {"\<\"abcdefabcdefabcd\"\>"},
    {"\<\"abcdefabcdefabcdef\"\>"},
    {"\<\"abcdefabcdefabcdefab\"\>"},
    {"\<\"abcdefabcdefabcdefabcd\"\>"},
    {"\<\"abcdefabcdefabcdefabcdef\"\>"}
   },
   GridBoxAlignment->{"Columns" -> {{Left}}},
   GridBoxItemSize->{"Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}],
  "Column"]], "Output"]
}, Open  ]]
}, Closed]],

Cell[CellGroupData[{

Cell[TextData[StyleBox["StringPowerQ", "Input"]], "Subsubsection"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"?", "StringPowerQ"}]], "Input"],

Cell[BoxData[
 StyleBox["\<\"StringPowerQ[\*StyleBox[\\\"string\\\", \\\"TI\\\"]] yields \
True if \*StyleBox[\\\"string\\\", \\\"TI\\\"] is a power of a smaller \
string, and yields False otherwise.\"\>", "MSG"]], "Print", "PrintUsage",
 CellTags->"Info3463241953-9817271"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"Select", "[", 
  RowBox[{
   RowBox[{"Join", "@@", 
    RowBox[{"Table", "[", 
     RowBox[{
      RowBox[{"StringTuples", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{"\"\<0\>\"", ",", "\"\<1\>\""}], "}"}], ",", "n"}], "]"}], 
      ",", 
      RowBox[{"{", 
       RowBox[{"n", ",", "0", ",", "4"}], "}"}]}], "]"}]}], ",", 
   "StringPowerQ"}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{"\<\"\"\>", ",", "\<\"00\"\>", ",", "\<\"11\"\>", 
   ",", "\<\"000\"\>", ",", "\<\"111\"\>", ",", "\<\"0000\"\>", 
   ",", "\<\"0101\"\>", ",", "\<\"1010\"\>", ",", "\<\"1111\"\>"}], 
  "}"}]], "Output"]
}, Open  ]],

Cell[TextData[{
 "Words that are not powers are sometimes called ",
 StyleBox["primitive",
  FontSlant->"Italic"],
 "."
}], "Text"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"Select", "[", 
  RowBox[{
   RowBox[{"Join", "@@", 
    RowBox[{"Table", "[", 
     RowBox[{
      RowBox[{"StringTuples", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{"\"\<0\>\"", ",", "\"\<1\>\""}], "}"}], ",", "n"}], "]"}], 
      ",", 
      RowBox[{"{", 
       RowBox[{"n", ",", "0", ",", "4"}], "}"}]}], "]"}]}], ",", 
   RowBox[{
    RowBox[{"!", 
     RowBox[{"StringPowerQ", "[", "#1", "]"}]}], "&"}]}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{"\<\"0\"\>", ",", "\<\"1\"\>", ",", "\<\"01\"\>", ",", "\<\"10\"\>",
    ",", "\<\"001\"\>", ",", "\<\"010\"\>", ",", "\<\"011\"\>", 
   ",", "\<\"100\"\>", ",", "\<\"101\"\>", ",", "\<\"110\"\>", 
   ",", "\<\"0001\"\>", ",", "\<\"0010\"\>", ",", "\<\"0011\"\>", 
   ",", "\<\"0100\"\>", ",", "\<\"0110\"\>", ",", "\<\"0111\"\>", 
   ",", "\<\"1000\"\>", ",", "\<\"1001\"\>", ",", "\<\"1011\"\>", 
   ",", "\<\"1100\"\>", ",", "\<\"1101\"\>", ",", "\<\"1110\"\>"}], 
  "}"}]], "Output"]
}, Open  ]]
}, Closed]],

Cell[CellGroupData[{

Cell[TextData[StyleBox["StringReplaceRepeated", "Input"]], "Subsubsection"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"?", "StringReplaceRepeated"}]], "Input"],

Cell[BoxData[
 StyleBox["\<\"StringReplaceRepeated[\*StyleBox[\\\"string\\\", \\\"TI\\\"], \
\*StyleBox[\\\"rules\\\", \\\"TI\\\"]] repeatedly performs replacements on \
\*StyleBox[\\\"string\\\", \\\"TI\\\"] until the result no longer \
changes.\\nStringReplaceRepeated[\*StyleBox[\\\"string\\\", \\\"TI\\\"], \
\*StyleBox[\\\"rules\\\", \\\"TI\\\"], \*StyleBox[\\\"n\\\", \\\"TI\\\"]] \
stops after at most \*StyleBox[\\\"n\\\", \\\"TI\\\"] \
steps.\\nStringReplaceRepeated[\*StyleBox[\\\"string\\\", \\\"TI\\\"], \
\*StyleBox[\\\"rules\\\", \\\"TI\\\"], \*StyleBox[\\\"n\\\", \\\"TI\\\"], \
\*StyleBox[\\\"l\\\", \\\"TI\\\"]] truncates at length \*StyleBox[\\\"l\\\", \
\\\"TI\\\"] at each step.\"\>", "MSG"]], "Print", "PrintUsage",
 CellTags->"Info3463241958-3683815"]
}, Open  ]],

Cell["\<\
Cancel inverses in a group element:\
\>", "Text"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"StringReplaceRepeated", "[", 
  RowBox[{
   RowBox[{"\"\\"", "<>", "\"\\""}], ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"\"\\"", "\[Rule]", "\"\<\>\""}], ",", 
     RowBox[{"\"\\"", "\[Rule]", "\"\<\>\""}], ",", 
     RowBox[{"\"\\"", "\[Rule]", "\"\<\>\""}], ",", 
     RowBox[{"\"\\"", "\[Rule]", "\"\<\>\""}]}], "}"}]}], "]"}]], "Input"],

Cell[BoxData["\<\"aaBaabAB\"\>"], "Output"]
}, Open  ]],

Cell["\<\
Perform replacements on overlapping substrings that do not change the \
characters on which they overlap:\
\>", "Text"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"StringReplaceRepeated", "[", 
  RowBox[{"\"\<{{a,b,c,d}{a,b}{a,b,c}}\>\"", ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"\"\<}{\>\"", "\[Rule]", "\"\<},{\>\""}], ",", 
     RowBox[{"\"\<{a,\>\"", "\[Rule]", "\"\<{\>\""}]}], "}"}]}], 
  "]"}]], "Input"],

Cell[BoxData["\<\"{{b,c,d},{b},{b,c}}\"\>"], "Output"]
}, Open  ]],

Cell["The Fibonacci morphism:", "Text"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"StringReplaceRepeated", "[", 
  RowBox[{"\"\<0\>\"", ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"\"\<0\>\"", "\[Rule]", "\"\<01\>\""}], ",", 
     RowBox[{"\"\<1\>\"", "\[Rule]", "\"\<0\>\""}]}], "}"}], ",", "8"}], 
  "]"}]], "Input"],

Cell[BoxData["\<\"0100101001001010010100100101001001010010100100101001010\"\>\
"], "Output"]
}, Open  ]],

Cell["\<\
Truncating at a certain length lets one easily compute the prefix of a fixed \
point:\
\>", "Text"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"StringReplaceRepeated", "[", 
  RowBox[{"\"\<0\>\"", ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"\"\<0\>\"", "\[Rule]", "\"\<011\>\""}], ",", 
     RowBox[{"\"\<1\>\"", "\[Rule]", "\"\<010\>\""}]}], "}"}], ",", 
   "\[Infinity]", ",", "100"}], "]"}]], "Input"],

Cell[BoxData["\<\"\
011010010011010011011010011011010010011010011011010010011010010011010011011010\
0100110100100110100110\"\>"], "Output"]
}, Open  ]]
}, Closed]],

Cell[CellGroupData[{

Cell[TextData[StyleBox["StringRiffle", "Input"]], "Subsubsection"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"?", "StringRiffle"}]], "Input"],

Cell[BoxData[
 StyleBox["\<\"StringRiffle[\*StyleBox[\\\"string\\\", \\\"TI\\\"], \
\*StyleBox[\\\"x\\\", \\\"TI\\\"]] inserts the string \*StyleBox[\\\"x\\\", \
\\\"TI\\\"] between every character in \*StyleBox[\\\"string\\\", \
\\\"TI\\\"].\\nStringRiffle[\*StyleBox[\\\"string\\\", \\\"TI\\\"], \
\*StyleBox[\\\"x\\\", \\\"TI\\\"], \*StyleBox[\\\"n\\\", \\\"TI\\\"]] inserts \
\*StyleBox[\\\"x\\\", \\\"TI\\\"] every \*StyleBox[\\\"n\\\", \\\"TI\\\"] \
characters.\\nStringRiffle[\*StyleBox[\\\"string\\\", \\\"TI\\\"], \
\*StyleBox[\\\"x\\\", \\\"TI\\\"], {\!\(\*SubscriptBox[StyleBox[\\\"i\\\", \\\
\"TI\\\"], StyleBox[\\\"min\\\", \\\"TI\\\"]]\), \!\(\*SubscriptBox[StyleBox[\
\\\"i\\\", \\\"TI\\\"], StyleBox[\\\"max\\\", \\\"TI\\\"]]\), \
\*StyleBox[\\\"n\\\", \\\"TI\\\"]}] inserts \*StyleBox[\\\"x\\\", \\\"TI\\\"] \
if possible at positions \!\(\*SubscriptBox[StyleBox[\\\"i\\\", \\\"TI\\\"], \
StyleBox[\\\"min\\\", \\\"TI\\\"]]\), \!\(\*SubscriptBox[StyleBox[\\\"i\\\", \
\\\"TI\\\"], StyleBox[\\\"min\\\", \\\"TI\\\"]]\) + \*StyleBox[\\\"n\\\", \
\\\"TI\\\"], \!\(\*SubscriptBox[StyleBox[\\\"i\\\", \\\"TI\\\"], \
StyleBox[\\\"min\\\", \\\"TI\\\"]]\) + 2 \*StyleBox[\\\"n\\\", \\\"TI\\\"], \
\[Ellipsis], \!\(\*SubscriptBox[StyleBox[\\\"i\\\", \\\"TI\\\"], \
StyleBox[\\\"max\\\", \\\"TI\\\"]]\).\"\>", "MSG"]], "Print", "PrintUsage",
 CellTags->"Info3463241969-9291729"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"StringRiffle", "[", 
  RowBox[{"\"\<12345678901234567890\>\"", ",", "\"\\""}], "]"}]], "Input"],

Cell[BoxData["\<\"1xy2xy3xy4xy5xy6xy7xy8xy9xy0xy1xy2xy3xy4xy5xy6xy7xy8xy9xy0\"\
\>"], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"StringRiffle", "[", 
  RowBox[{"\"\<12345678901234567890\>\"", ",", "\"\\"", ",", "3"}], 
  "]"}]], "Input"],

Cell[BoxData["\<\"12x34x56x78x90x12x34x56x78x90\"\>"], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"StringRiffle", "[", 
  RowBox[{"\"\<12345678901234567890\>\"", ",", "\"\\"", ",", 
   RowBox[{"{", 
    RowBox[{"5", ",", 
     RowBox[{"-", "9"}], ",", "5"}], "}"}]}], "]"}]], "Input"],

Cell[BoxData["\<\"1234x5678x9012x34567890\"\>"], "Output"]
}, Open  ]]
}, Closed]],

Cell[CellGroupData[{

Cell[TextData[{
 StyleBox["StringRotateLeft", "Input"],
 StyleBox[" and ",
  FontWeight->"Plain"],
 StyleBox["StringRotateRight", "Input"]
}], "Subsubsection"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"?", "StringRotateLeft"}]], "Input"],

Cell[BoxData[
 StyleBox["\<\"StringRotateLeft[\*StyleBox[\\\"string\\\", \\\"TI\\\"], \
\*StyleBox[\\\"n\\\", \\\"TI\\\"]] cycles the characters in a string \
\*StyleBox[\\\"n\\\", \\\"TI\\\"] positions to the \
left.\\nStringRotateLeft[\*StyleBox[\\\"string\\\", \\\"TI\\\"]] cycles one \
position to the left.\"\>", "MSG"]], "Print", "PrintUsage",
 CellTags->"Info3463241974-9550623"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"StringRotateLeft", "[", 
  RowBox[{"\"\\"", ",", "3"}], "]"}]], "Input"],

Cell[BoxData["\<\"defghiabc\"\>"], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"?", "StringRotateRight"}]], "Input"],

Cell[BoxData[
 StyleBox["\<\"StringRotateRight[\*StyleBox[\\\"string\\\", \\\"TI\\\"], \
\*StyleBox[\\\"n\\\", \\\"TI\\\"]] cycles the characters in a string \
\*StyleBox[\\\"n\\\", \\\"TI\\\"] positions to the \
right.\\nStringRotateRight[\*StyleBox[\\\"string\\\", \\\"TI\\\"]] cycles one \
position to the right.\"\>", "MSG"]], "Print", "PrintUsage",
 CellTags->"Info3463241975-1575743"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"StringRotateRight", "[", 
  RowBox[{"\"\\"", ",", "3"}], "]"}]], "Input"],

Cell[BoxData["\<\"ghiabcdef\"\>"], "Output"]
}, Open  ]]
}, Closed]],

Cell[CellGroupData[{

Cell[TextData[StyleBox["StringTally", "Input"]], "Subsubsection"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"?", "StringTally"}]], "Input"],

Cell[BoxData[
 StyleBox["\<\"StringTally[\*StyleBox[\\\"string\\\", \\\"TI\\\"]] tallies \
the characters in \*StyleBox[\\\"string\\\", \\\"TI\\\"], listing all \
distinct characters together with their \
multiplicities.\\nStringTally[\*StyleBox[\\\"string\\\", \\\"TI\\\"], \
\*StyleBox[\\\"n\\\", \\\"TI\\\"]] tallies the subwords in \
\*StyleBox[\\\"string\\\", \\\"TI\\\"] of length \*StyleBox[\\\"n\\\", \\\"TI\
\\\"].\"\>", "MSG"]], "Print", "PrintUsage",
 CellTags->"Info3463241979-3976710"]
}, Open  ]],

Cell["Count letters in the beginning of the Fibonacci word:", "Text"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"StringTally", "[", 
  RowBox[{"StringReplaceRepeated", "[", 
   RowBox[{"\"\<0\>\"", ",", 
    RowBox[{"{", 
     RowBox[{
      RowBox[{"\"\<0\>\"", "\[Rule]", "\"\<01\>\""}], ",", 
      RowBox[{"\"\<1\>\"", "\[Rule]", "\"\<0\>\""}]}], "}"}], ",", "8"}], 
   "]"}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{
   RowBox[{"{", 
    RowBox[{"\<\"0\"\>", ",", "34"}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"\<\"1\"\>", ",", "21"}], "}"}]}], "}"}]], "Output"]
}, Open  ]],

Cell["\<\
Count subwords of length 4 in the beginning of the Thue\[Dash]Morse word:\
\>", "Text"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"StringTally", "[", 
  RowBox[{
   RowBox[{"StringReplaceRepeated", "[", 
    RowBox[{"\"\<0\>\"", ",", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"\"\<0\>\"", "\[Rule]", "\"\<01\>\""}], ",", 
       RowBox[{"\"\<1\>\"", "\[Rule]", "\"\<10\>\""}]}], "}"}], ",", "8"}], 
    "]"}], ",", "4"}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{
   RowBox[{"{", 
    RowBox[{"\<\"0110\"\>", ",", "43"}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"\<\"1101\"\>", ",", "21"}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"\<\"1010\"\>", ",", "21"}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"\<\"0100\"\>", ",", "21"}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"\<\"1001\"\>", ",", "42"}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"\<\"0011\"\>", ",", "21"}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"\<\"1100\"\>", ",", "21"}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"\<\"0010\"\>", ",", "21"}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"\<\"0101\"\>", ",", "21"}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"\<\"1011\"\>", ",", "21"}], "}"}]}], "}"}]], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"StringTally", "[", 
  RowBox[{"\"\<\>\"", ",", "2"}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", "}"}]], "Output"]
}, Open  ]]
}, Closed]],

Cell[CellGroupData[{

Cell[TextData[StyleBox["StringTuples", "Input"]], "Subsubsection"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"?", "StringTuples"}]], "Input"],

Cell[BoxData[
 StyleBox["\<\"StringTuples[{\!\(\*SubscriptBox[StyleBox[\\\"s\\\", \
\\\"TI\\\"], StyleBox[\\\"1\\\", \\\"TR\\\"]]\), \!\(\*SubscriptBox[StyleBox[\
\\\"s\\\", \\\"TI\\\"], StyleBox[\\\"2\\\", \\\"TR\\\"]]\), \*StyleBox[\\\"\
\[Ellipsis]\\\", \\\"TI\\\"], \!\(\*SubscriptBox[StyleBox[\\\"s\\\", \\\"TI\\\
\"], StyleBox[\\\"k\\\", \\\"TI\\\"]]\)}, \*StyleBox[\\\"n\\\", \\\"TI\\\"]] \
generates a list of all possible words of length \*StyleBox[\\\"n\\\", \\\"TI\
\\\"] on a given alphabet.\"\>", "MSG"]], "Print", "PrintUsage",
 CellTags->"Info3463241985-7578867"]
}, Open  ]],

Cell["Find all words on three letters:", "Text"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"StringTuples", "[", 
  RowBox[{
   RowBox[{"{", 
    RowBox[{"\"\\"", ",", "\"\\"", ",", "\"\\""}], "}"}], ",", 
   "3"}], "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{"\<\"aaa\"\>", ",", "\<\"aab\"\>", ",", "\<\"aac\"\>", 
   ",", "\<\"aba\"\>", ",", "\<\"abb\"\>", ",", "\<\"abc\"\>", 
   ",", "\<\"aca\"\>", ",", "\<\"acb\"\>", ",", "\<\"acc\"\>", 
   ",", "\<\"baa\"\>", ",", "\<\"bab\"\>", ",", "\<\"bac\"\>", 
   ",", "\<\"bba\"\>", ",", "\<\"bbb\"\>", ",", "\<\"bbc\"\>", 
   ",", "\<\"bca\"\>", ",", "\<\"bcb\"\>", ",", "\<\"bcc\"\>", 
   ",", "\<\"caa\"\>", ",", "\<\"cab\"\>", ",", "\<\"cac\"\>", 
   ",", "\<\"cba\"\>", ",", "\<\"cbb\"\>", ",", "\<\"cbc\"\>", 
   ",", "\<\"cca\"\>", ",", "\<\"ccb\"\>", ",", "\<\"ccc\"\>"}], 
  "}"}]], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"StringTuples", "[", 
  RowBox[{
   RowBox[{"{", 
    RowBox[{"\"\<01\>\"", ",", "\"\<011\>\""}], "}"}], ",", "3"}], 
  "]"}]], "Input"],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{"\<\"010101\"\>", ",", "\<\"0101011\"\>", ",", "\<\"0101101\"\>", 
   ",", "\<\"01011011\"\>", ",", "\<\"0110101\"\>", ",", "\<\"01101011\"\>", 
   ",", "\<\"01101101\"\>", ",", "\<\"011011011\"\>"}], "}"}]], "Output"]
}, Open  ]]
}, Closed]]
}, Open  ]]
}, Open  ]]
},
AutoGeneratedPackage->None,
WindowSize->{1272, 717},
WindowMargins->{{Automatic, 0}, {Automatic, 0}},
ShowSelection->True,
TrackCellChangeTimes->False,
FrontEndVersion->"7.0 for Microsoft Windows (64-bit) (February 18, 2009)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{
 "Info3463241922-8143798"->{
  Cell[11034, 397, 266, 4, 40, "Print",
   CellTags->"Info3463241922-8143798"]},
 "Info3463241934-3512694"->{
  Cell[12813, 477, 549, 9, 58, "Print",
   CellTags->"Info3463241934-3512694"]},
 "Info3463241942-6239304"->{
  Cell[18063, 678, 540, 9, 58, "Print",
   CellTags->"Info3463241942-6239304"]},
 "Info3463241947-8776518"->{
  Cell[19859, 739, 568, 8, 58, "Print",
   CellTags->"Info3463241947-8776518"]},
 "Info3463241953-9817271"->{
  Cell[21911, 811, 274, 4, 40, "Print",
   CellTags->"Info3463241953-9817271"]},
 "Info3463241958-3683815"->{
  Cell[24257, 891, 773, 11, 75, "Print",
   CellTags->"Info3463241958-3683815"]},
 "Info3463241969-9291729"->{
  Cell[27309, 992, 1385, 19, 76, "Print",
   CellTags->"Info3463241969-9291729"]},
 "Info3463241974-9550623"->{
  Cell[29799, 1061, 386, 6, 58, "Print",
   CellTags->"Info3463241974-9550623"]},
 "Info3463241975-1575743"->{
  Cell[30477, 1084, 390, 6, 58, "Print",
   CellTags->"Info3463241975-1575743"]},
 "Info3463241979-3976710"->{
  Cell[31256, 1112, 498, 8, 58, "Print",
   CellTags->"Info3463241979-3976710"]},
 "Info3463241985-7578867"->{
  Cell[33982, 1208, 578, 8, 42, "Print",
   CellTags->"Info3463241985-7578867"]}
 }
*)
(*CellTagsIndex
CellTagsIndex->{
 {"Info3463241922-8143798", 36348, 1276},
 {"Info3463241934-3512694", 36458, 1279},
 {"Info3463241942-6239304", 36568, 1282},
 {"Info3463241947-8776518", 36678, 1285},
 {"Info3463241953-9817271", 36788, 1288},
 {"Info3463241958-3683815", 36898, 1291},
 {"Info3463241969-9291729", 37009, 1294},
 {"Info3463241974-9550623", 37121, 1297},
 {"Info3463241975-1575743", 37232, 1300},
 {"Info3463241979-3976710", 37343, 1303},
 {"Info3463241985-7578867", 37454, 1306}
 }
*)
(*NotebookFileOutline
Notebook[{
Cell[CellGroupData[{
Cell[567, 22, 34, 0, 83, "Title"],
Cell[604, 24, 42, 0, 49, "Subtitle"],
Cell[649, 26, 222, 6, 47, "Subsubtitle"],
Cell[CellGroupData[{
Cell[896, 36, 31, 0, 71, "Section"],
Cell[930, 38, 399, 8, 47, "Text"],
Cell[1332, 48, 405, 11, 29, "Text"],
Cell[1740, 61, 56, 1, 47, "Code"],
Cell[CellGroupData[{
Cell[1821, 66, 49, 0, 36, "Subsection"],
Cell[1873, 68, 399, 18, 30, "Text"],
Cell[CellGroupData[{
Cell[2297, 90, 100, 2, 31, "Input"],
Cell[2400, 94, 59, 0, 30, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[2496, 99, 91, 2, 31, "Input"],
Cell[2590, 103, 149, 3, 30, "Output"]
}, Open  ]],
Cell[2754, 109, 80, 2, 29, "Text"],
Cell[CellGroupData[{
Cell[2859, 115, 265, 7, 31, "Input"],
Cell[3127, 124, 103, 2, 30, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[3267, 131, 951, 23, 92, "Input"],
Cell[4221, 156, 67, 0, 30, "Output"],
Cell[4291, 158, 67, 0, 30, "Output"],
Cell[4361, 160, 31, 0, 30, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[4429, 165, 211, 6, 31, "Input"],
Cell[4643, 173, 167, 3, 30, "Output"]
}, Open  ]],
Cell[4825, 179, 107, 3, 29, "Text"],
Cell[CellGroupData[{
Cell[4957, 186, 241, 6, 31, "Input"],
Cell[5201, 194, 2382, 70, 50, "Output"]
}, Open  ]],
Cell[7598, 267, 122, 3, 30, "Text"],
Cell[CellGroupData[{
Cell[7745, 274, 175, 5, 31, "Input"],
Cell[7923, 281, 628, 11, 30, "Output"]
}, Open  ]]
}, Closed]],
Cell[CellGroupData[{
Cell[8600, 298, 29, 0, 28, "Subsection"],
Cell[8632, 300, 184, 4, 30, "Text"],
Cell[8819, 306, 153, 5, 31, "Input"],
Cell[CellGroupData[{
Cell[8997, 315, 162, 4, 31, "Input"],
Cell[9162, 321, 558, 20, 30, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[9757, 346, 475, 13, 31, "Input"],
Cell[10235, 361, 319, 8, 57, "Output"]
}, Open  ]],
Cell[10569, 372, 63, 1, 31, "Input"]
}, Closed]]
}, Open  ]],
Cell[CellGroupData[{
Cell[10681, 379, 34, 0, 71, "Section"],
Cell[CellGroupData[{
Cell[10740, 383, 211, 7, 28, "Subsubsection"],
Cell[CellGroupData[{
Cell[10976, 394, 55, 1, 31, "Input"],
Cell[11034, 397, 266, 4, 40, "Print",
 CellTags->"Info3463241922-8143798"]
}, Open  ]],
Cell[11315, 404, 47, 0, 29, "Text"],
Cell[CellGroupData[{
Cell[11387, 408, 49, 1, 31, "Input"],
Cell[11439, 411, 28, 0, 30, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[11504, 416, 60, 1, 31, "Input"],
Cell[11567, 419, 89, 2, 30, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[11693, 426, 258, 9, 42, "Input"],
Cell[11954, 437, 259, 9, 43, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[12250, 451, 60, 1, 31, "Input"],
Cell[12313, 454, 306, 10, 43, "Output"]
}, Open  ]]
}, Closed]],
Cell[CellGroupData[{
Cell[12668, 470, 64, 0, 22, "Subsubsection"],
Cell[CellGroupData[{
Cell[12757, 474, 53, 1, 31, "Input"],
Cell[12813, 477, 549, 9, 58, "Print",
 CellTags->"Info3463241934-3512694"]
}, Open  ]],
Cell[13377, 489, 49, 0, 29, "Text"],
Cell[CellGroupData[{
Cell[13451, 493, 164, 4, 31, "Input"],
Cell[13618, 499, 548, 20, 30, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[14203, 524, 438, 12, 31, "Input"],
Cell[14644, 538, 117, 3, 30, "Output"]
}, Open  ]],
Cell[14776, 544, 38, 0, 29, "Text"],
Cell[CellGroupData[{
Cell[14839, 548, 168, 4, 31, "Input"],
Cell[15010, 554, 1078, 39, 30, "Output"]
}, Open  ]],
Cell[16103, 596, 114, 3, 29, "Text"],
Cell[CellGroupData[{
Cell[16242, 603, 168, 4, 31, "Input"],
Cell[16413, 609, 880, 32, 30, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[17330, 646, 137, 3, 31, "Input"],
Cell[17470, 651, 389, 14, 30, "Output"]
}, Open  ]]
}, Closed]],
Cell[CellGroupData[{
Cell[17908, 671, 69, 0, 22, "Subsubsection"],
Cell[CellGroupData[{
Cell[18002, 675, 58, 1, 31, "Input"],
Cell[18063, 678, 540, 9, 58, "Print",
 CellTags->"Info3463241942-6239304"]
}, Open  ]],
Cell[CellGroupData[{
Cell[18640, 692, 106, 2, 31, "Input"],
Cell[18749, 696, 133, 3, 30, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[18919, 704, 119, 2, 31, "Input"],
Cell[19041, 708, 116, 3, 30, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[19194, 716, 124, 2, 31, "Input"],
Cell[19321, 720, 342, 6, 30, "Output"]
}, Open  ]]
}, Closed]],
Cell[CellGroupData[{
Cell[19712, 732, 65, 0, 22, "Subsubsection"],
Cell[CellGroupData[{
Cell[19802, 736, 54, 1, 31, "Input"],
Cell[19859, 739, 568, 8, 58, "Print",
 CellTags->"Info3463241947-8776518"]
}, Open  ]],
Cell[CellGroupData[{
Cell[20464, 752, 96, 2, 31, "Input"],
Cell[20563, 756, 45, 0, 30, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[20645, 761, 98, 2, 31, "Input"],
Cell[20746, 765, 65, 0, 30, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[20848, 770, 290, 8, 47, "Input"],
Cell[21141, 780, 572, 18, 207, "Output"]
}, Open  ]]
}, Closed]],
Cell[CellGroupData[{
Cell[21762, 804, 66, 0, 22, "Subsubsection"],
Cell[CellGroupData[{
Cell[21853, 808, 55, 1, 31, "Input"],
Cell[21911, 811, 274, 4, 40, "Print",
 CellTags->"Info3463241953-9817271"]
}, Open  ]],
Cell[CellGroupData[{
Cell[22222, 820, 403, 13, 31, "Input"],
Cell[22628, 835, 243, 5, 30, "Output"]
}, Open  ]],
Cell[22886, 843, 131, 5, 29, "Text"],
Cell[CellGroupData[{
Cell[23042, 852, 470, 15, 31, "Input"],
Cell[23515, 869, 526, 9, 30, "Output"]
}, Open  ]]
}, Closed]],
Cell[CellGroupData[{
Cell[24090, 884, 75, 0, 22, "Subsubsection"],
Cell[CellGroupData[{
Cell[24190, 888, 64, 1, 31, "Input"],
Cell[24257, 891, 773, 11, 75, "Print",
 CellTags->"Info3463241958-3683815"]
}, Open  ]],
Cell[25045, 905, 59, 2, 29, "Text"],
Cell[CellGroupData[{
Cell[25129, 911, 411, 9, 31, "Input"],
Cell[25543, 922, 43, 0, 30, "Output"]
}, Open  ]],
Cell[25601, 925, 129, 3, 29, "Text"],
Cell[CellGroupData[{
Cell[25755, 932, 280, 7, 31, "Input"],
Cell[26038, 941, 54, 0, 30, "Output"]
}, Open  ]],
Cell[26107, 944, 39, 0, 29, "Text"],
Cell[CellGroupData[{
Cell[26171, 948, 264, 7, 31, "Input"],
Cell[26438, 957, 92, 1, 30, "Output"]
}, Open  ]],
Cell[26545, 961, 109, 3, 29, "Text"],
Cell[CellGroupData[{
Cell[26679, 968, 290, 7, 31, "Input"],
Cell[26972, 977, 139, 2, 30, "Output"]
}, Open  ]]
}, Closed]],
Cell[CellGroupData[{
Cell[27160, 985, 66, 0, 22, "Subsubsection"],
Cell[CellGroupData[{
Cell[27251, 989, 55, 1, 31, "Input"],
Cell[27309, 992, 1385, 19, 76, "Print",
 CellTags->"Info3463241969-9291729"]
}, Open  ]],
Cell[CellGroupData[{
Cell[28731, 1016, 124, 2, 31, "Input"],
Cell[28858, 1020, 95, 1, 30, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[28990, 1026, 136, 3, 31, "Input"],
Cell[29129, 1031, 64, 0, 30, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[29230, 1036, 213, 5, 31, "Input"],
Cell[29446, 1043, 58, 0, 30, "Output"]
}, Open  ]]
}, Closed]],
Cell[CellGroupData[{
Cell[29553, 1049, 159, 5, 22, "Subsubsection"],
Cell[CellGroupData[{
Cell[29737, 1058, 59, 1, 31, "Input"],
Cell[29799, 1061, 386, 6, 58, "Print",
 CellTags->"Info3463241974-9550623"]
}, Open  ]],
Cell[CellGroupData[{
Cell[30222, 1072, 108, 2, 31, "Input"],
Cell[30333, 1076, 44, 0, 30, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[30414, 1081, 60, 1, 31, "Input"],
Cell[30477, 1084, 390, 6, 58, "Print",
 CellTags->"Info3463241975-1575743"]
}, Open  ]],
Cell[CellGroupData[{
Cell[30904, 1095, 109, 2, 31, "Input"],
Cell[31016, 1099, 44, 0, 30, "Output"]
}, Open  ]]
}, Closed]],
Cell[CellGroupData[{
Cell[31109, 1105, 65, 0, 22, "Subsubsection"],
Cell[CellGroupData[{
Cell[31199, 1109, 54, 1, 31, "Input"],
Cell[31256, 1112, 498, 8, 58, "Print",
 CellTags->"Info3463241979-3976710"]
}, Open  ]],
Cell[31769, 1123, 69, 0, 29, "Text"],
Cell[CellGroupData[{
Cell[31863, 1127, 308, 8, 31, "Input"],
Cell[32174, 1137, 189, 6, 30, "Output"]
}, Open  ]],
Cell[32378, 1146, 97, 2, 29, "Text"],
Cell[CellGroupData[{
Cell[32500, 1152, 339, 9, 31, "Input"],
Cell[32842, 1163, 763, 22, 30, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[33642, 1190, 94, 2, 31, "Input"],
Cell[33739, 1194, 45, 1, 30, "Output"]
}, Open  ]]
}, Closed]],
Cell[CellGroupData[{
Cell[33833, 1201, 66, 0, 22, "Subsubsection"],
Cell[CellGroupData[{
Cell[33924, 1205, 55, 1, 31, "Input"],
Cell[33982, 1208, 578, 8, 42, "Print",
 CellTags->"Info3463241985-7578867"]
}, Open  ]],
Cell[34575, 1219, 48, 0, 29, "Text"],
Cell[CellGroupData[{
Cell[34648, 1223, 175, 5, 31, "Input"],
Cell[34826, 1230, 628, 11, 30, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[35491, 1246, 159, 5, 31, "Input"],
Cell[35653, 1253, 257, 4, 30, "Output"]
}, Open  ]]
}, Closed]]
}, Open  ]]
}, Open  ]]
}
]
*)

(* End of internal cache information *)