2
$\begingroup$

I am looking for a way to get the output of FullForm in Command Line under Linux (Debian) using -noprompt argument.

Example : What I have : a+b*c

What I want : Plus[a, Times[b, c]].

I can have it like this (without -noprompt but I get useless text)

#  echo 'FullForm[a+b*c]' | math
Mathematica blah blah
Out[1]//FullForm= Plus[a, Times[b, c]]

Usually to avoid the "blah blah" I use "-noprompt" but here is what I get with -noprompt :

#  echo 'FullForm[a+b*c]' | math -noprompt
FullForm[a + b*c]

So my question is How to get the Correct Output ? (with noprompt)

Any advice ?

Thank you.

$\endgroup$
5
  • 1
    $\begingroup$ You mean FullForm[Hold[1 + 1]]? $\endgroup$ Dec 26, 2014 at 18:28
  • $\begingroup$ I dunno why it answers FullForm[Hold[1+1]] $\endgroup$
    – Crypto
    Dec 28, 2014 at 19:12
  • $\begingroup$ it seems in fact true that the behaviour is different $\endgroup$
    – chris
    Jan 2, 2015 at 21:43
  • $\begingroup$ @chris I confirm also the problem (v.10.0.2, OS X 10.9.5). For example echo 'FullForm[{1,2,3}]' | /Applications/Mathematica.app/Contents/MacOS/MathKernel -noprompt returns FullForm[{1, 2, 3}] and not List[1, 2, 3] (as in the interactive mode). Same problem also if I put the command in a file e.g. "test.m" and execute /Applications/Mathematica.app/Contents/MacOS/MathematicaScript -script test.m. In both cases, no problem if I replace the FullForm command by any other like Plus[1,1]. $\endgroup$
    – SquareOne
    Jan 3, 2015 at 3:17
  • 1
    $\begingroup$ If I try echo 'z=a+b*c';FullForm[z] | .... it also returns FullForm[a + b*c] $\endgroup$
    – SquareOne
    Jan 3, 2015 at 3:21

1 Answer 1

3
$\begingroup$

The -noprompt switch does several things: it suppresses the Mathematica ... banner and all the In/Out prompts, sets the page width to Infinity and, most relevantly, switches the kernel default print form to InputForm (being preferable, in batch mode, to the regular two-dimensional typesetting used for interactive terminal sessions).

Example : What I have : a+b*c

What I want : Plus[a, Times[b, c]]

$ echo 'OutputForm @ FullForm[a+b*c]' | math -noprompt          
Plus[a, Times[b, c]]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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