TransWikia.com

Locally remove definition of function

Mathematica Asked on January 7, 2021

Consider the following code

g[x_]:=x^2
f[x_]:=2*g[x]
f[x] (* returns 2 x^2*)
test[x_]:=Module[{g},f[x]]
test[x] (* returns 2 x^2 as well*)

What I would like to have and the reason why I thought module would have been fine to use is to locally remove the definition of g so that test[x] returns me 2*g[x].

I want to do it by only modifying what appears inside the definition of my function test[x], I don’t have the right to modify the definitions of f or g.

How is it possible to do it ?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP