MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: rhs of SetDelayed

  • To: mathgroup at
  • Subject: [mg1657] Re: [mg1584] rhs of SetDelayed
  • From: Allan Hayes <hay%haystack at>
  • Date: Tue, 11 Jul 1995 02:57:09 -0400

In [mg1584] rhs of SetDelayed
Michael Probst <c7081naa at>

>I have to define a few functions that take the same arguments.
>Therefore I don't want to write the list of agguments repeatedly
>and use a variable instead.
>The following approach:
>does not work. The left side is o.k. but since rhsArg is not
>converted to {a1,a2,a3,a4} the right side is not.
>How does one do this ?


The following, using With, may help: I give two variants.


{a1, a2, a3, a4} = {1, 2, 3, 4};
	(*to check there is no unwanted evaluation *)

With[{lhsArg ={a1_,a2_,a3_,a4_},rhsArg:={a1,a2,a3,a4}},
	f[lhsArg]:= g[rhsArg]];

With[{lhsArg = Sequence[a1_,a2_,a3_,a4_], 	
      rhsArg:= Sequence[a1,a2,a3,a4]
	f[lhsArg]:= g[rhsArg]

	f[{a1_, a2_, a3_, a4_}] := g[{a1, a2, a3, a4}]
	f[a1_, a2_, a3_, a4_] := g[a1, a2, a3, a4]

Notice the use of := in With to simply insert unevaluated.


With[{lhsArg ={a1_,a2_,a3_,a4_},rhsArg ={a1,a2,a3,a4}},
	f[lhsArg]:= g[rhsArg];]

	f[{a1_, a2_, a3_, a4_}] := g[{1, 2, 3, 4}]
g will never be evaluated.

Allan Hayes
hay at

  • Prev by Date: Re: Masked array operations
  • Next by Date: Re: Masked array operations
  • Previous by thread: Re: rhs of SetDelayed
  • Next by thread: Bug in Mma 2.2.2 for Windows?