9
$\begingroup$

Bug introduced in 7.0 and fixed in 10.0.0


Maybe this is a bug or maybe Infix acts differently than the other functions.

The fact is that both:

TreeForm[Infix[f[x, a]]]

and

ToString[Infix[f[x, a]]]

crash the kernel. I use Mathematica 9.0 and maybe there are other cases that Infix behaves strangely.

Does anybody can explain why this happens ?

$\endgroup$
2
  • 1
    $\begingroup$ confirmed (9.000). $\endgroup$
    – george2079
    Dec 4, 2013 at 19:08
  • $\begingroup$ I confirm this behavior for Mathematica 8.0.4 under Windows 7 x64. $\endgroup$ Dec 5, 2013 at 7:06

2 Answers 2

4
$\begingroup$

Hack workaround..

infix[f_] := Infix[f, "~" <> SymbolName[Head[f]] <> "~"];
ToString[infix[f[a, b, c]]]

-> "a~f~b~f~c"
$\endgroup$
4
  • $\begingroup$ Nice hack to get the String , but the TreeForm seems awkward. I am parsing some mma expressions and I would like to use the embedded functions as they are. So I am still puzzled... I would like to know the real reason why Infix fails above. $\endgroup$
    – tchronis
    Dec 4, 2013 at 19:43
  • $\begingroup$ Also ToString[ Hold@(Infix[f[x, a], "~" <> SymbolName[Head[f[x, a]]] <> "~"]) ] crashes the kernel. Removing Hold or replacing with HoldAll works ok ... $\endgroup$
    – tchronis
    Dec 4, 2013 at 20:05
  • 3
    $\begingroup$ note this also crashes: OutputForm[Infix[f[a, b]]] -- seems like a question for Wolfram support. $\endgroup$
    – george2079
    Dec 4, 2013 at 20:07
  • 1
    $\begingroup$ Sent to Wolfram support. I will update here when they send a feedback. Thanks @george2079 $\endgroup$
    – tchronis
    Dec 5, 2013 at 6:05
3
$\begingroup$

This bug has been fixed as of version 10.0.0.

ToString[Infix[f[x, a]]]                                                
(* "x ~f~ a" *)

OutputForm[Infix[f[x, a]]]                                              
(* x ~f~ a *)
$\endgroup$

Your Answer

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

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