# Replace constant with expression [closed]

How can I replace a constant a in a certain expression with a function f[z_]:=1+z?

I tried the following:

expr = a/c
(*a/c*)
expr = Replace[expr, a -> f[z]]
(*a/c*)


The desired result would be expr=(1 + z)/c

## closed as off-topic by m_goldberg, Itai Seggev, LCarvalho, Daniel Lichtblau, yohbsJul 20 '17 at 4:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, Itai Seggev, LCarvalho, Daniel Lichtblau, yohbs
If this question can be reworded to fit the rules in the help center, please edit the question.

• If really want to update expr, try expr = expr /. a -> f[z] – m_goldberg Jul 19 '17 at 0:42
• Or use the correct function name, which is ReplaceAll. – Itai Seggev Jul 19 '17 at 3:10

Use the third argument of Replace to specify the level as 1:

f[x_] := 1 + x;
expr = a/c;
expr = Replace[expr, a -> f[z], 1]


(1 + z)/c