Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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

 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


(* 2 *)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.