       Self destructing definitions

• To: mathgroup at yoda.physics.unc.edu
• Subject: Self destructing definitions
• From: LELMA at basin.crc.uno.edu
• Date: Mon, 9 Mar 1992 14:14 CST

```A colleague of mine is having the following problem with definitions that seem
to overwrite each other:

In:=
rowOp[A_?MatrixQ,c_opcode] :=
(A[[c[]]] = A[[c[]]] c[]
/; c[] == 1)

In:=
rowOp[A_?MatrixQ,c_opcode] :=
(A[[c[]]] = A[[c[]]] + c[] A[[c[]]]
/; c[] == 3)

(*  We now find the first definition has been overwritten by the second. *)

In:= ?rowOp

Out=
rowOp
rowOp/: rowOp[(A_)?MatrixQ, c_opcode] :=

A[[c[]]] =

A[[c[]]] + c[] A[[c[]]] /; c[] == 3

(*   If the first definition is now repeated, it in turn overwrites the second
definition.  *)

In:=  rowOp[A_?MatrixQ,c_opcode] :=
(A[[c[]]] = A[[c[]]] c[]
/; c[] == 1)

In:=  ?rowOp

Out=  rowOp
rowOp/: rowOp[(A_)?MatrixQ, c_opcode] :=
A[[c[]]] = A[[c[]]] c[] /; c[] == 1

In the original source of this problem, the function rowOp had the
attribute  HoldFirst.  The above shows that this is not needed to produce the
problem.  Changing the name of the pattern c to something else in one or the
other definition allows both to coexist.

What's going wrong?
Any help would be appreciated,  Thanks.

Lew Lefton
Department of Mathematics
University of New Orleans
New Orleans, Louisiana  70148
Phone:          (504) 286-6331
E-mail address:  lelma at uno.edu  (OR lelma at uno.bitnet)

```

• Prev by Date: RE: Partial Fraction Decomposition with imaginary coeff.
• Next by Date: finding roots of user defn. functions
• Previous by thread: Symbolic integration of piecewise defined functions
• Next by thread: finding roots of user defn. functions