(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 12.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 158, 7] NotebookDataLength[ 12876, 374] NotebookOptionsPosition[ 10842, 321] NotebookOutlinePosition[ 11221, 337] CellTagsIndexPosition[ 11178, 334] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["Basic Examples", "Subsection", CellID->462042388], Cell["Split a sequence when an element is even:", "Text", CellChangeTimes->{{3.756038062725909*^9, 3.756038078504282*^9}}, CellID->13078159], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ InterpretationBox[ TagBox[ StyleBox[ StyleBox[ FrameBox[GridBox[{ { StyleBox[ StyleBox[ AdjustmentBox["\<\"[\[FilledSmallSquare]]\"\>", BoxBaselineShift->-0.25, BoxMargins->{{0, 0}, {-1, -1}}], "ResourceFunctionIcon", FontColor->RGBColor[ 0.8745098039215686, 0.2784313725490196, 0.03137254901960784]], ShowStringCharacters->False, FontFamily->"Source Sans Pro Black", FontSize->Rational[10, 13] Inherited, FontWeight->"Heavy", PrivateFontOptions->{"OperatorSubstitution"->False}], StyleBox[ StyleBox["\<\"SplitWhen\"\>", "ResourceFunctionLabel"], ShowStringCharacters->False, FontSize->Rational[12, 13] Inherited]} }]], "ResourceFunctionFrame"], FrameBoxOptions->{Background->GrayLevel[0.5, 0.15], BaseStyle->{ "StandardForm", LineSpacing -> {0, 0}, LineBreakWithin -> False}, FrameMargins->{{3, 3}, {0, 0}}, FrameStyle->Directive[ GrayLevel[0.5, 0.35], AbsoluteThickness[0.5]], RoundingRadius->4}, GridBoxOptions->{FrameStyle->GrayLevel[1, 0], GridBoxAlignment->{"Columns" -> {{Left}}, "Rows" -> {{Automatic}}}, GridBoxFrame->{"Columns" -> {{True}}, "Rows" -> {{True}}}, GridBoxItemSize->{"Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}, GridBoxSpacings->{"Columns" -> {{0.25}}, "Rows" -> {-0.1, {}, 0}}}], {"FunctionResourceBox", RGBColor[0.8745098039215686, 0.2784313725490196, 0.03137254901960784], "\"SplitWhen\""}], ResourceFunction["SplitWhen"], BoxID -> "SplitWhen", Selectable->False], "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"Fibonacci", "[", "n", "]"}], ",", RowBox[{"{", RowBox[{"n", ",", "20"}], "}"}]}], "]"}], ",", "EvenQ"}], "]"}]], "Input", CellChangeTimes->{{3.755964653570463*^9, 3.755964666498213*^9}, 3.755979964125842*^9, {3.7559830830290537`*^9, 3.7559831128442993`*^9}, { 3.755983586529798*^9, 3.755983618506257*^9}}, CellLabel->"In[1]:=", CellID->1873732334], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "1", ",", "2"}], "}"}], ",", RowBox[{"{", RowBox[{"3", ",", "5", ",", "8"}], "}"}], ",", RowBox[{"{", RowBox[{"13", ",", "21", ",", "34"}], "}"}], ",", RowBox[{"{", RowBox[{"55", ",", "89", ",", "144"}], "}"}], ",", RowBox[{"{", RowBox[{"233", ",", "377", ",", "610"}], "}"}], ",", RowBox[{"{", RowBox[{"987", ",", "1597", ",", "2584"}], "}"}], ",", RowBox[{"{", RowBox[{"4181", ",", "6765"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{{3.755964662871141*^9, 3.755964666654726*^9}, { 3.755983083734982*^9, 3.7559831134302464`*^9}, {3.755983592833824*^9, 3.75598361889878*^9}, 3.756128814484267*^9}, CellLabel->"Out[1]=", CellID->137475325] }, Open ]], Cell["Split at every occurrence of an element:", "Text", CellChangeTimes->{{3.7559828744871283`*^9, 3.75598292207901*^9}}, CellID->1801508228], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{ InterpretationBox[ TagBox[ StyleBox[ StyleBox[ FrameBox[GridBox[{ { StyleBox[ StyleBox[ AdjustmentBox["\<\"[\[FilledSmallSquare]]\"\>", BoxBaselineShift->-0.25, BoxMargins->{{0, 0}, {-1, -1}}], "ResourceFunctionIcon", FontColor->RGBColor[ 0.8745098039215686, 0.2784313725490196, 0.03137254901960784]], ShowStringCharacters->False, FontFamily->"Source Sans Pro Black", FontSize->Rational[10, 13] Inherited, FontWeight->"Heavy", PrivateFontOptions->{"OperatorSubstitution"->False}], StyleBox[ StyleBox["\<\"SplitWhen\"\>", "ResourceFunctionLabel"], ShowStringCharacters->False, FontSize->Rational[12, 13] Inherited]} }]], "ResourceFunctionFrame"], FrameBoxOptions->{Background->GrayLevel[0.5, 0.15], BaseStyle->{ "StandardForm", LineSpacing -> {0, 0}, LineBreakWithin -> False}, FrameMargins->{{3, 3}, {0, 0}}, FrameStyle->Directive[ GrayLevel[0.5, 0.35], AbsoluteThickness[0.5]], RoundingRadius->4}, GridBoxOptions->{FrameStyle->GrayLevel[1, 0], GridBoxAlignment->{"Columns" -> {{Left}}, "Rows" -> {{Automatic}}}, GridBoxFrame->{"Columns" -> {{True}}, "Rows" -> {{True}}}, GridBoxItemSize->{"Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}, GridBoxSpacings->{"Columns" -> {{0.25}}, "Rows" -> {-0.1, {}, 0}}}], {"FunctionResourceBox", RGBColor[0.8745098039215686, 0.2784313725490196, 0.03137254901960784], "\"SplitWhen\""}], ResourceFunction["SplitWhen"], BoxID -> "SplitWhen", Selectable->False], "[", RowBox[{ RowBox[{"{", RowBox[{ "x", ",", "x", ",", "r", ",", "b", ",", "y", ",", "r", ",", "c", ",", "z"}], "}"}], ",", RowBox[{ RowBox[{"#", "\[Equal]", "r"}], "&"}]}], "]"}]], "Input", CellChangeTimes->{{3.7559828375283947`*^9, 3.755982846204241*^9}, { 3.755982998518601*^9, 3.755983006594521*^9}}, CellLabel->"In[2]:=", CellID->380172702], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"x", ",", "x", ",", "r"}], "}"}], ",", RowBox[{"{", RowBox[{"b", ",", "y", ",", "r"}], "}"}], ",", RowBox[{"{", RowBox[{"c", ",", "z"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{ 3.7559828464487123`*^9, {3.75598300081953*^9, 3.755983007146167*^9}, 3.7561288208546906`*^9}, CellLabel->"Out[2]=", CellID->297692772] }, Open ]], Cell["Split at every occurrence of an negative integer:", "Text", CellChangeTimes->{{3.7559828744871283`*^9, 3.75598292207901*^9}, { 3.756046305793172*^9, 3.756046307341267*^9}, {3.756046372881735*^9, 3.756046374189904*^9}}, CellID->2136481028], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Split", "[", RowBox[{ RowBox[{"{", RowBox[{"2", ",", "0", ",", RowBox[{"-", "1"}], ",", "4", ",", "2", ",", RowBox[{"-", "1"}], ",", "1", ",", RowBox[{"-", "2"}], ",", RowBox[{"-", "1"}], ",", RowBox[{"-", "4"}]}], "}"}], ",", RowBox[{ RowBox[{ RowBox[{"Sign", "[", "#1", "]"}], "\[Equal]", "1"}], "&"}]}], "]"}]], "Input", CellChangeTimes->{{3.756046252113723*^9, 3.756046271604775*^9}, { 3.756046327150425*^9, 3.756046363982498*^9}}, CellLabel->"In[3]:=", CellID->1017066135], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"2", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"-", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"4", ",", "2", ",", RowBox[{"-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", RowBox[{"-", "2"}]}], "}"}], ",", RowBox[{"{", RowBox[{"-", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"-", "4"}], "}"}]}], "}"}]], "Output", CellChangeTimes->{{3.756046254661165*^9, 3.756046272039199*^9}, { 3.756046353544024*^9, 3.7560463643852654`*^9}, 3.756128824174885*^9}, CellLabel->"Out[3]=", CellID->202770347] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Applications", "Subsection", CellID->568056528], Cell["Number of integers to find a prime:", "Text", CellChangeTimes->{{3.7559828744871283`*^9, 3.755982883428672*^9}}, CellID->1688333870], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Length", "/@", RowBox[{ InterpretationBox[ TagBox[ StyleBox[ StyleBox[ FrameBox[GridBox[{ { StyleBox[ StyleBox[ AdjustmentBox["\<\"[\[FilledSmallSquare]]\"\>", BoxBaselineShift->-0.25, BoxMargins->{{0, 0}, {-1, -1}}], "ResourceFunctionIcon", FontColor->RGBColor[ 0.8745098039215686, 0.2784313725490196, 0.03137254901960784]], ShowStringCharacters->False, FontFamily->"Source Sans Pro Black", FontSize->Rational[10, 13] Inherited, FontWeight->"Heavy", PrivateFontOptions->{"OperatorSubstitution"->False}], StyleBox[ StyleBox["\<\"SplitWhen\"\>", "ResourceFunctionLabel"], ShowStringCharacters->False, FontSize->Rational[12, 13] Inherited]} }]], "ResourceFunctionFrame"], FrameBoxOptions->{Background->GrayLevel[0.5, 0.15], BaseStyle->{ "StandardForm", LineSpacing -> {0, 0}, LineBreakWithin -> False}, FrameMargins->{{3, 3}, {0, 0}}, FrameStyle->Directive[ GrayLevel[0.5, 0.35], AbsoluteThickness[0.5]], RoundingRadius->4}, GridBoxOptions->{FrameStyle->GrayLevel[1, 0], GridBoxAlignment->{"Columns" -> {{Left}}, "Rows" -> {{Automatic}}}, GridBoxFrame->{"Columns" -> {{True}}, "Rows" -> {{True}}}, GridBoxItemSize->{"Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}, GridBoxSpacings->{"Columns" -> {{0.25}}, "Rows" -> {-0.1, {}, 0}}}], {"FunctionResourceBox", RGBColor[0.8745098039215686, 0.2784313725490196, 0.03137254901960784], "\"SplitWhen\""}], ResourceFunction["SplitWhen"], BoxID -> "SplitWhen", Selectable->False], "[", RowBox[{ RowBox[{"Range", "[", "20", "]"}], ",", "PrimeQ"}], "]"}]}]], "Input", CellChangeTimes->{{3.755982597015203*^9, 3.7559826156772118`*^9}, { 3.755982661093643*^9, 3.755982667800332*^9}, {3.755982726746221*^9, 3.755982757706724*^9}, {3.7559828565483103`*^9, 3.755982858980462*^9}}, CellLabel->"In[1]:=", CellID->958726127], Cell[BoxData[ RowBox[{"{", RowBox[{ "2", ",", "1", ",", "2", ",", "2", ",", "4", ",", "2", ",", "4", ",", "2", ",", "1"}], "}"}]], "Output", CellChangeTimes->{{3.755982597882722*^9, 3.755982668184149*^9}, { 3.7559827339438257`*^9, 3.755982758101893*^9}, 3.755982859657851*^9, 3.7561288288576355`*^9}, CellLabel->"Out[1]=", CellID->320942981] }, Open ]] }, Open ]] }, WindowSize->{808, 855}, WindowMargins->{{436, Automatic}, {Automatic, 50}}, FrontEndVersion->"12.0 for Mac OS X x86 (64-bit) (April 8, 2019)", StyleDefinitions->"Default.nb", $CellContext`ClosingSaveDialog -> False ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[580, 22, 56, 1, 70, "Subsection",ExpressionUUID->"682b93dc-d0fb-48b3-842a-106616db6e78", CellID->462042388], Cell[639, 25, 142, 2, 70, "Text",ExpressionUUID->"55cf1938-0e7f-40d2-98c0-681a81b0f510", CellID->13078159], Cell[CellGroupData[{ Cell[806, 31, 2196, 56, 70, "Input",ExpressionUUID->"ba4a8d7b-36a2-4577-bd33-cfe08e62e716", CellID->1873732334], Cell[3005, 89, 785, 21, 70, "Output",ExpressionUUID->"8f9f1d54-d407-4918-a7b6-866a53096523", CellID->137475325] }, Open ]], Cell[3805, 113, 144, 2, 70, "Text",ExpressionUUID->"c967e694-6161-4046-a230-af1329c3fa04", CellID->1801508228], Cell[CellGroupData[{ Cell[3974, 119, 2133, 55, 70, "Input",ExpressionUUID->"b8c19586-7fcc-40ad-a484-a9554f14cf61", CellID->380172702], Cell[6110, 176, 413, 13, 70, "Output",ExpressionUUID->"87e3ac8d-b336-44cb-a0c0-197c8adf2345", CellID->297692772] }, Open ]], Cell[6538, 192, 251, 4, 70, "Text",ExpressionUUID->"94e5f89b-edc9-4c54-bc97-76e79c8522b8", CellID->2136481028], Cell[CellGroupData[{ Cell[6814, 200, 563, 17, 70, "Input",ExpressionUUID->"69cce0b6-81b9-48b4-9183-3b5534d3b8d4", CellID->1017066135], Cell[7380, 219, 627, 20, 70, "Output",ExpressionUUID->"c211828f-c736-46b3-987e-bb700e2ad456", CellID->202770347] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[8056, 245, 54, 1, 70, "Subsection",ExpressionUUID->"250c4657-934f-450f-b44c-011e0a83b3b6", CellID->568056528], Cell[8113, 248, 140, 2, 70, "Text",ExpressionUUID->"03fec0ee-0767-4cb1-8733-7b7a81c405a8", CellID->1688333870], Cell[CellGroupData[{ Cell[8278, 254, 2172, 52, 70, "Input",ExpressionUUID->"3da464f1-26b1-456c-8acf-dccaeea17b88", CellID->958726127], Cell[10453, 308, 361, 9, 70, "Output",ExpressionUUID->"8e4f2e47-2882-41a9-b761-95f2c31307e6", CellID->320942981] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)