Infix strange behaviour


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]]]


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 ?


Posted 2013-12-04T18:54:57.020

Reputation: 2 385

1confirmed (9.000). – george2079 – 2013-12-04T19:08:20.797

I confirm this behavior for Mathematica 8.0.4 under Windows 7 x64. – Alexey Popkov – 2013-12-05T07:06:01.037



Hack workaround..

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

-> "a~f~b~f~c"


Posted 2013-12-04T18:54:57.020

Reputation: 37 858

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. – tchronis – 2013-12-04T19:43:30.013

Also ToString[ Hold@(Infix[f[x, a], "~" <> SymbolName[Head[f[x, a]]] <> "~"]) ] crashes the kernel. Removing Hold or replacing with HoldAll works ok ... – tchronis – 2013-12-04T20:05:01.917

3note this also crashes: OutputForm[Infix[f[a, b]]] -- seems like a question for Wolfram support. – george2079 – 2013-12-04T20:07:36.847

1Sent to Wolfram support. I will update here when they send a feedback. Thanks @george2079 – tchronis – 2013-12-05T06:05:41.500


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 *)


Posted 2013-12-04T18:54:57.020

Reputation: 24 492