I have troubles to output an entire symbol, a function in this case, from a module or a block. For instance

 myf = Block[{f}, f[3] = 33; f[4] = 4; f]

Then I want to get the values of f from the module valorization, but I get

 In[531]:= myf[3]

 Out[531]= f(3)

instead I would like to get the value that I have put in the module, in this case `

 "desired behaviour"

 In[531]:= myf[3]

 Out[531]= 33

I might be asking a RTFM question, but I do not see it answered anywhere. Thanks for your help, Roberto


1 Answer 1


This will probably be closed as a duplicate of either:

In the meantime the simple answer is that you need Module rather than Block, because the former creates a new Symbol whereas the latter merely temporarily changes the value of Symbol.

myf = Module[{f}, f[3] = 33; f[4] = 4; f]

In the example f$1464 is the new Symbol that was created by Module.


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.