MathGroup Archive 2003

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

Search the Archive

Re: List Operations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg38719] Re: List Operations
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Tue, 7 Jan 2003 07:26:08 -0500 (EST)
  • Organization: Universitaet Leipzig
  • References: <av6jub$nug$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

SetAttributes[BackSet, HoldAll]

$backsetList = {}

BackSet[a_, b_] := (a = b; AppendTo[$backsetList, {Hold[a], Hold[b]}];)

Unprotect[Set]
Set[a_, b_] /; 
    MemberQ[(First /@ $backsetList) /. Hold[q_] :> Unevaluated[q], a] := 
  Module[{pos, what},
    pos = Position[$backsetList, a];
    Print[Part[$backsetList, Sequence @@ pos[[1]]]];
    what = Part[$backsetList, Sequence @@ pos[[1]]];
    Block[{$backsetList = {}},
      Evaluate[what] = b;
      a = b]
    ]


and

BackSet[status, {len1, len2}];
status = {3, 2}


will work.

Regards
  Jens

Hermann Schmitt wrote:
> 
> Hi,
> 1)
> in the following example len1 and len2 are assigned values.
> In[2]=status = {len1, len2}
> status1 = {3, 4};
> {len1, len2} = status1;
> Print["status: ", status];
> Print["len1: ", len1, "  len2: ", len2]
> 
> Out[2]= {len1, len2}
> status: {3, 4}
> len1: 3  len2: 4
> In[7]:=
> 
> 2)
> In this example, len1 and len2 are not assigned values, because status1 is
> assigned to status directly.
> In[2]=status = {len1, len2}
> status1 = {3, 4};
> status = status1;
> Print["status: ", status];
> Print["len1: ", len1, "  len2: ", len2]
> 
> Out[2]= {len1, len2}
> status: {3, 4}
> len1: len1  len2: len2
> In[7]:=
> 
> My question is:
> Can the result of example 1) be achieved in any way using the variables
> status and status1
> Hermann Schmitt


  • Prev by Date: Re: Re: OOP experiments in Mathematica- The Stack
  • Next by Date: Multiplelistplot question
  • Previous by thread: Re: List Operations
  • Next by thread: OOP experiments- Component