Tag Info

New answers tagged


This answer is in the same spirit as Kuba's answer, but it avoids conversion between boxes and expressions. Here is our workhorse mark::usage = "Use in combination with markedExpression"; markedExpressify::usage = "Use mark to mark strings for conversion to expressions"; markedExpressify[expr_] := Module[{pos, hCExpr, ext, thr, rLH, expresser}, ...


So recently I've learned from John Fultz that RawBoxes are kind of verbatim indicator for MakeBoxes which is not well stressed out in documentation. This or I've missed the point but it doesn't matter, here we have handy way to do this: x = 5; ToExpression @ MakeBoxes[RawBoxes["x"] = 123]; x 123


Barbarism can be avoided through judicious application of DownValues. Using RolfMertig's suggestion, you can get what you want with f[alpha] = "artichoke"; f[bravo] = "beet"; f[charlie] = "celery"; ... f[yankee] = "yam"; f[zulu] = "zucchini"; DownValues[f][[All, 1, 1, 1]] (* -> {alpha, bravo, charlie, ..., yankee, zulu} *)


expandNCM[(h : NonCommutativeMultiply)[a___, b_Plus, c___]] := Distribute[h[a, b, c], Plus, h, Plus, ExpandNCM[h[##]] &] expandNCM[(h : NonCommutativeMultiply)[a___, b_Times, c___]] := Most[b] ExpandNCM[h[a, Last[b], c]] expandNCM[a_] := ExpandAll[a] To eliminate ** operators: compressNCM[expr_] := expr /. NonCommutativeMultiply[x__] :> ...

Top 50 recent answers are included