# Preventing an output of a function from being assigned a value

Say I have a function

Example[n_Integer]:=n{x,y,z}

Example@4

{4 x, 4 y, 4 z}

Now, let us assign some values to x,y,z

x=7 y=7 z=8

And then we evaluate our function again

Example@4

{28, 28, 32}

How can I make it so that despite some values being assigned to the variables x,y,z the output of the function Example is only affected by its argument n? I have tried to use SetAttributes[Example,Protected] but that does not work. Could someone help?

• Can you provide more details of why you want to do this? I think you oversimplified your actual issue. – Carl Woll May 28 at 21:13
• @CarlWoll I produce a list of symbolic expression, for instance {-x,-y,x,y,x+y,y+z.} – amator2357 May 28 at 21:17
• So, something like: Example[n_Integer]:=(Clear[x,y,z]; n{x,y,z}) will work for you? – Carl Woll May 28 at 21:20
• @CarlWoll I produce a list of symbolic expressions, for instance l = {-x,-y,x,y,x+y,y+z}. I then write a function that assigns some expression to x and y, for example x={1,-1,0},y={0,1,-1} so then automatically the remaining symbols in l get assigned a value. Then I want to find a reflection of one of the expression in l in the hyperplane perpendicular to, say x. Once I do that, I'd get, for example, {-1,1,0}. Now, I want to know to which symbol in my initial l that value corresponds, if that makes sense. – amator2357 May 28 at 21:25
• This sounds very much like an XY problem. Can you maybe update your question to reflect what you are truly after? – Roman May 28 at 21:45

Just avoid setting x and y.

For example:

f2[l_, n_] := n l;

Clear[x, y, z]
masterl = {x, y, z};


Then you can substitute in values if you want:

xx = 3; yy = 4;
l2 = masterl /. {x -> xx, y -> yy}

(* {3, 4, z} *)


Or do some work with the original list:

f2[masterl, 5]

(* {5 x, 5 y, 5 z} *)