Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I want to run my Mathematica scripts from the terminal and I want it to print lines like MATLAB would. That is, suppress output by ending a line with ;, and otherwise print the output of the line. Get (<<) only prints the last line.

Without using Print[var] and saving variables after every line... Is this possible?

share|improve this question
2  
Your scripts ought to have Print[] lines somewhere in the file, then... –  J. M. Oct 31 '12 at 12:50
    
"...without using Print[var]..." - why? –  J. M. Oct 31 '12 at 14:42
2  
I think adding // Print after every line is the best I can do, saves me from having to Print specific variables... –  user1788553 Oct 31 '12 at 14:43
    
without using Print[var] because I don't want to have to put in specific variables, I want a general solution... –  user1788553 Oct 31 '12 at 14:43
    
In that case, I suppose postfix application of Print[] is what you want, indeed. –  J. M. Oct 31 '12 at 14:45
show 4 more comments

1 Answer 1

You print by having a Print[] on the expression you want to print. End all other statements with ;.

fooToPrint = bar[...]; Print[fooToPrint];  
fooNoPrint = bar[...];

e.g.,

a = 1 + 2;
Print[a];

b = 3 + 4;

a = b;
Print[a];
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.