lshifr / CodeFormatter

A pretty-printer for Mathematica language, working on the box level
Other
33 stars 7 forks source link

modification on preprocess #7

Open SilviaHyde opened 10 years ago

SilviaHyde commented 10 years ago

Modified preprocess so it can handle this case:

cellbox = 
  RowBox[{RowBox[{"gcd", "[", RowBox[{"m0_", ",", "n0_"}], "]"}], 
    ":=", "\[IndentingNewLine]", 
    RowBox[{"Module", "[", 
      RowBox[{RowBox[{"{", 
          RowBox[{RowBox[{"m", "=", "m0"}], ",", 
            RowBox[{"n", "=", "n0"}]}], "}"}], ",", 
        "\[IndentingNewLine]", 
        RowBox[{RowBox[{"While", "[", 
            RowBox[{RowBox[{"n", "\[NotEqual]", "0"}], ",", 
              RowBox[{RowBox[{"{", RowBox[{"m", ",", "n"}], "}"}], 
                "=", "     ", 
                RowBox[{"{", 
                  RowBox[{"n", ",", 
                    RowBox[{"Mod", "[", 
                    RowBox[{"m", ",", "      ", "n"}], "]"}]}], 
                  "}"}]}]}], "]"}], ";", "\[IndentingNewLine]", 
          RowBox[{RowBox[{"m", " ", "n"}], "+", 
            RowBox[{"2", " ", "3"}], "+", 
            RowBox[{"4", "     ", "5"}]}]}]}], "\[IndentingNewLine]", 
      "]"}]}];
FullCodeFormat[cellbox] // CellPrint[Cell[BoxData[#], "Input"]] &

image