The row icon in the Basic Math Assistant palette

Hello everyone,

In the Basic Math Assistant palette, there’s a Row icon (two squares) that’s equivalent to {{ a,b}}. Is there a way to perform the inverse operation? That is, to convert {{a,b}} to that format?

Regards,
Sinval

Maybe you are looking to display your row in TraditionalForm?

MatrixForm alternatively produces similar results.

Hi David,

I would like it to revert to the same format that appears in the palette, that is, the two squares.

I don’t know of a built-in way. You could make a button to do it. Something like the following:

Button["gridify",
 With[{mat = MakeExpression[
     NotebookRead[EvaluationNotebook[]],
     StandardForm]},
  If[MatrixQ[Thread /@ Thread[mat]],
   NotebookWrite[
    EvaluationNotebook[],
    GridBox @@ Replace[
      mat,
      _ :> "\[Placeholder]",
      {3}
      ]
    ],
   Message[General::matrix, "selection", 1]
   ]
  ]
 ]

It converts a selection to the grid of placeholders, if the selection is a matrix. You could put such a function into a palette.

Another way is to create the grid from a matrix, fill it in, and paste it where you want:

mat = {{a, b}};
CellPrint[Cell[BoxData[GridBox[Map["\[Placeholder]" &, mat, {2}]]], "Input"]]

Finally, do you know about control-comma and control-return? They create the type of grid you want. I find it easy to hold the control key down and hit comma or return until I have a matrix of the right dimensions. If I overshoot, I can select a row or column and hit delete.

In terms of how I like to use Mathematica, my three suggestions go from worst (but cleverest?) to best, for some reason. The only reason I can think for using one of the cleverer approaches is to create a user-interface in which I want to create an input grid that depends on user input. Otherwise, control-comma/return is what I actually do all the time.

Yes, I know the key combinations control-comma and control-return and I use them quite often. The second procedure you created works well.

Thank you very much for the information, Michael.