MathGroup Archive 2009

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

Search the Archive

Re: Selecting left hand sides from assignments

On Mar 22, 3:47 am, "E. Martin-Serrano"
<eMartinSerr... at> wrote:
> -----Original Message-----
> From: E. Martin-Serrano [mailto:eMartinSerr... at]
> Sent: Tuesday, March 17, 2009 10:58 AM
> Subject:  Selecting left hand sides from assignments
> >Hi,
> >I need help on the following.
> >From the list of assignments:
> >assignmentslist = {LHS1 = RHS1, LHS2 = RHS2, LHS3 = RHS3, ..., L=
HSi = RHSi,
> ..., LHSn = RSHn}
> >I need to extract all the left hand sides (symbols) within a list like:
> >lhslist = {LHS, LHS2, LHS3, ..., LHSi, ..., LHSn}
> >Where the left hand sides are all symbols and the right hand sides are a=
> expression.
> >E. Martin-Serrano
> -------------------------------------------
> Hi again,
> In dealing with the subject of my post above I came across the article (i=
> notebook form) by Robby Villegas (Wolfram Research) about Working with
> Unevaluated Expressions, which begins:
> "Most experienced Mathematica programmers will eventually encounter tasks=
> applications in which they need to manipulate expressions without letting
> them evaluate. (=85) Since Mathematica automatically evaluates argument=
s and
> return values of functions, building up a result without exposing
> intermediate stages of work to the evaluator requires subtle techniques t=
> even seasoned Mathematica programmers sometimes find elusive. In this
> tutorial, I will demonstrate situations in which evaluation control is
> important, pointing out common pitfalls and providing useful tools and
> techniques along the way."
> Before posting my question above, I have spent some time looking for my o=
> way to the solution but I did not get to prevent the lhs of assignments f=
> being assigned at all. The lack of responses to my question tells me that
> either it is fairly clumsy or there is not an easy answer. So I insist.
> One of the sources I consulted in my search was the Robby's article
> mentioned above. However the only thing I found in it about *Set* and
> *SetDelay* tells me that these are not the easiest clauses or commands to=
> "manipulated" in the way I want. Robby Villegas himself ends the article
> with some remarks about "Left-hand side of but leaving them without any
> treatment; insisting in how special they are and saying that both command=
> can be made more flexible. Then he announces that he will expand the arti=
> to solve the following issues:
> - Evaluate certain parts of *SetDelayed* rhs as exceptions.
> - Don't evaluate certain parts of *Set* rhs as exceptions.
> Robby finally says: "I will include these examples in the next revision o=
> this document (Working with Unevaluated Expressions)."
> Now, since "leaving unevaluated certain parts of *Set* rhs as exceptions"=
> the main part of the solution to my problem, my question is:
> Does anyone know whether Robby Villegas wrote his next revision of the
> document including the new material, and, if so, where I could find it?
> The Robby Villegas's notebook was referenced in the last version that I k=
> of the Ted Ersek Tricks.
> I hope Robby himself read this post.
> Best regards
> E. martin-Serrano.

assignmentList = Hold[a = 1, b = 2, c = 3];

Apply assignments: ReleaseHold[assignmentList];

Get LHS: assignmentList[[All, 1]] ==> Hold[a, b, c]

I'll gladly explain more and/or alternative methods if you supply a
better example and explain why/how you are using this mechanism.

  • Prev by Date: Re: Problem using a dialog and dynamic
  • Next by Date: Re: Got a tip ?
  • Previous by thread: Re: Re: Selecting left hand sides from assignments
  • Next by thread: Kernel is quitting on me