Mathematica中的批量输入和输出?

Ale*_*kov 7 wolfram-mathematica

最近,我发现了一些旧帖子上MathGroup其中无证命令行选项的使用-batchinput-batchoutput所示:

 If test.mma contains the following commands:

    a=2+2
    b=10!;
    a+b

 then, running Mathematica in batch mode, only output for the first and 
 third commands goes to stdout:

    # math -batchinput -batchoutput < test.mma

    4

    3628804
Run Code Online (Sandbox Code Playgroud)

但是当尝试在Windows下重现此行为时,我只在控制台窗口中打印出第一个输出.我究竟做错了什么?

Dr.*_*ius 7

我测试了它并将两个数字作为输出.但是,如果最后一个命令后面没有回车符,那么输出就是你发布的内容!

因此,请检查您是否以回车结束最后一行.

  • 谢谢!问题是最后一行没有以换行符结尾. (2认同)