Tag Info

New answers tagged

3

You did not state that you wished to avoid making additional assignments upon a System` Symbol, therefore that is a natural approach and it is possible using Unprotect since ElementData is not Locked, and it appears to work correctly here: Unprotect[ElementData]; ElementData["Carbon", "Resonance"] = 42; ElementData["Phlebotinum", "AtomicWeight"] = 666; ...


1

Despite the accepted excellent answer by Mr.Wizard I think it is worth to point out that the standard idiomatic approach to the problem in Mathematica is to use indexed variables: In[1]:= i = 10; d[i] = 30; Definition[d] d[10] = 10; Definition[d] Out[3]= d[10] = 30 Out[5]= d[10] = 10


6

I shall assume that you want a compact syntax to make this practical to use. I shall choose cs, standing for compound symbol: func_[cs[x__], arg___] ^:= ToHeldExpression @ ToString @ Row @ {x} /. {_[s_Symbol] :> func[s, arg], _ :> $Failed} Test: i = 10; cs["d", i] = 30; d10 30 Any expressions can be used so long as their evaluated ...



Top 50 recent answers are included