Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.6K Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Saving and printing expressions

Posted 11 years ago

I need to save a bunch of expressions and together with a string describing each expression and print them out later. They print fine if I print them directly like this:

Print["riemann[[",ii,",",jj,",",kk,",",ll,"]]=",riemann[[ii,jj,kk,ll]]]

Of course, this is in a loop and the ii, jj, etc are set to specific values and riemann[[ii,jj,kk,ll]] evaluates to an expression and the expression gets printed. I have tried about a million ways to save the strings and the expressions and print them later but nothing works. For instance, this:

riemannA = {};
Append[riemannA,"riemann[[" <> ToString[ii] <> "," <> ToString[jj] <> "," <>ToString[kk] <> "," <> ToString[ll] <> "]]=" <>ToString[ riemann[[ii, jj, kk, ll]] ] ];

I would appreciate any suggestions how to go about this.

POSTED BY: James Strunk
2 Replies
Posted 11 years ago

I couldnt really get that to do what I want. This code will print one line exactly how I want: StringForm[rNZLabels[[1]], ToExpression[rNZExpressions[[1]]]. rNZLabels and rNZExpressions are one dimensional arrays. How do I get it to loop through the arrays and print a single StringForm on each line? This has to happen in a single cell of a Grid. I tried StringForms of Columns and Columns of StringForms and I tried coding a For loop directly in the cell and nothing works. I also tried Row[{ Column[rNZLabels], Column[ToExpression[rNZExpressions]] // StandardForm}]. That almost works. The only problem is that the alignment of the columns drifts because some expressions take more vertical height than others and they are generally higher than the text lines. I screwed around with a lot of the Alignment parameters but nothing helped.

POSTED BY: James Strunk

I would use $post instead.

 $Post=Print[#]&
 Table[foo[i], {i, 0, 10}]

Now all the expression are printed automatically. You can change the $Post to a function to do other things. You send the expressions to a file for example, or accumulate them in a list, etc... see

https://reference.wolfram.com/language/ref/$Post.html

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