Maxima Function
with_stdout (f, expr_1, expr_2, expr_3, ...)
with_stdout(s,expr_1,expr_2,expr_3,...)
Evaluates expr_1, expr_2, expr_3, ...
and writes any output thus generated to a file f or output stream s.
The evaluated expressions are not written to the output.
Output may be generated by print, display, grind,
among other functions.
The global flag file_output_append governs
whether with_stdout appends or truncates the output file f.
When file_output_append is true,
with_stdout appends to the output file.
Otherwise, with_stdout truncates the output file.
In either case, with_stdout creates the file if it does not yet exist.
with_stdout returns the value of its final argument.
(%i1) with_stdout ("tmp.out", for i:5 thru 10 do print (i, "! yields", i!))$ (%i2) printfile ("tmp.out")$ 5 ! yields 120 6 ! yields 720 7 ! yields 5040 8 ! yields 40320 9 ! yields 362880 10 ! yields 3628800