Message Boards Message Boards

0
|
619 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Two Helpful uses of $PrePrint

Posted 11 months ago

I would like to share a helpful setting for \ $PrePrint which prints matrices of dimensions less than or equal to 30 by 30 with MatrixForm and quantities with the quantity in SI. The reason I include the dimension limit is to avoid using MatrixForm on a very large SparseArray with tens of thousands of entries where MatrixQ returns True. Other ideas for $PrePrint include N, to avoid doing //N every time and FullSimplify to avoid doing FullSimplify every time, and TraditionalForm to avoid doing TraditionalForm every time.

$PrePrint = 
  Which[And @@ {MatrixQ[#], 
      MatchQ[Dimensions[#], {x_ /; x <= 30, z_ /; z <= 30}]}, 
    MatrixForm[#], QuantityQ[#], UnitConvert[#, "Metric"], True, 
    Identity[#]] &;

If you have an idea for a helpful thing to add to \ $PrePrint, please comment with your idea. It seems like most of the Q functions, accessed with Names["System`*Q"] might have applications with \$PrePrint.

POSTED BY: Peter Burbery
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract