Skip to main content
12 events
when toggle format what by license comment
Apr 13, 2017 at 12:55 history edited CommunityBot
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
May 24, 2016 at 18:22 vote accept Shredderroy
Nov 28, 2015 at 22:46 comment added Greg Hurst @xzczd Also note, running ./MathKernel from terminal, {x, a[1]} appears like you would expect. In[2]:= Clear@a; a /: b_[c__, a[d_]] := a[b[c, d]]; {x, a[1]} Out[2]= a[{x, 1}]
Nov 28, 2015 at 19:39 history edited Michael E2 CC BY-SA 3.0
Added explanation
Nov 28, 2015 at 19:10 comment added Michael E2 Didn't get this the first time: i.sstatic.net/94zsb.png -- ah, figured it out: the extra HoldComplete[ToString[whoCalled]] etc. are from the floating popup info. Note having the whoCalled def. around messes up the Preferences dialog window!
Nov 28, 2015 at 18:56 comment added Michael E2 @xzczd It seems to be the same thing. Try something like a /: mem : b_[c__, a[d_]] /; (Print[HoldComplete[mem]]; True) := a[b[c, d]];, which is basically the same thing as I did for Kuba's. Basic the def. is applied once to generate a[{x, 1}]` and then again, when the internal code accidentally matches the definition in formatting the output boxes. Note the code if of the form If[t, e1, e2, a[{x , 1}], where e1 is also a[{x, 1}] but is matched in c__.
Nov 28, 2015 at 18:11 comment added Greg Hurst @xzczd (I forgot to tag you).
Nov 28, 2015 at 18:10 comment added Greg Hurst If we give If a HoldAll attribute, we can see it's coming from formatting functions I believe. ClearAll@a; a /: b_[c__, a[d_]] := a[Print[Hold@{b, {c}, d}]; b[c, d]]; {x, a[1]} During evaluation of In[11]:= Hold[{List,{x},1}] During evaluation of In[11]:= Hold[{If,{!MemberQ[$BoxForms,StandardForm]||MatchQ[HoldComplete[a[{x,1}]],_[OutputSizeLimit`Dump`$unlimitedTextPattern]]||MatchQ[HoldComplete[a[{x,1}]], <<OMITTED FOR SPACE>>},{x,1}}] Out[12]= a[{x, 1}]
Nov 28, 2015 at 18:09 comment added Greg Hurst There's a weird thing happening with a mysterious If. In[9]:= ClearAll@a; a /: b_[c__, a[d_]] := a[Print[{b, {c}, d}]; b[c, d]]; {x, a[1]} During evaluation of In[9]:= {List,{x},1} During evaluation of In[9]:= {If,{False,a[{x,1}],a[{x,1}]},{x,1}} Out[9]= a[a[{x, 1}]]
Nov 28, 2015 at 17:36 comment added xzczd Do you have any idea on Clear@a; a /: b_[c__, a[d_]] := a[b[c, d]]; {x, a[1]}?
Nov 28, 2015 at 15:27 history edited Michael E2 CC BY-SA 3.0
Added explanation
Nov 28, 2015 at 14:43 history answered Michael E2 CC BY-SA 3.0