I need to change a function symbol multiple times by assigning another symbol to it, but when I'm trying to do that the symbols overwrite each other.
I'm assuming this is because the assignment is by reference.
For example, this input:
func1[x_] := x^2
func2 = func1; func3[x_] := func1[x]
{func1, func2, func3}
{func1[#], func2[#], func3[#]} &[4]
func1[x_] := -x
{func1[#], func2[#], func3[#]} &[4]
Gives the following output:
Out[]= {func1, func1, func3}
Out[]= {16, 16, 16}
Out[]= {-4, -4, -4}
How could I make the assignment so changing one function doesn't influence changing the other?
Function
s is often more appropriate than downvalue-definitions. When usingfunc1=Function[x,x^2]
for the first definition andfunc1=Function[x,-x]
for the second your example will work as you want... $\endgroup$