# How to pass arguments between functions

I have two Functions, f[] and g[]. f is passed some values ,say {w,x,y,z} and I want to send one of those to g say x. I don't want this operation to interfere with other operations.

• can you be more specific? eg why does g[x_]:=x; f[{w_,x_,y_,z_}]:=g[x] not work? – acl Dec 19 '12 at 12:31
• f[l_]:=(g[First@l]; whatever) – ssch Dec 19 '12 at 12:33
• @acl fine i'l tell you the entire problem. – santhosh Dec 19 '12 at 12:37
• you don't need to put the entire problem here, just some sort of minimal example – acl Dec 19 '12 at 12:38
• The better you explain your problem to us, the better the chances to get good answers. Your question style so far is kind of short bordering on incomplete. – Yves Klett Dec 19 '12 at 12:41

Is this what you have in mind by any chance? I'm simply using an external variable to store the x passed to f when f is called. The Module is there so that that external variable is only known by f and g and you don't accidentally use it in other places

Module[{var},
f[{w_, x_, y_, z_}] := (var = x; 8);
g[] := var
]


So now if you run

f[{1, 2, 3, 4}]


you get

(* 8 *)


But next time you run g[] you get the "x argument" passed to f the last time it was called

g[]

(* 2 *)