Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Selecting left hand sides from assignments

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97833] Re: Selecting left hand sides from assignments
  • From: Raffy <raffy at mac.com>
  • Date: Mon, 23 Mar 2009 04:03:14 -0500 (EST)
  • References: <gq54vc$80f$1@smc.vnet.net>

On Mar 22, 3:47 am, "E. Martin-Serrano"
<eMartinSerr... at telefonica.net> wrote:
> -----Original Message-----
> From: E. Martin-Serrano [mailto:eMartinSerr... at telefonica.net]
> 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=
ny
>
> expression.
>
> >E. Martin-Serrano
>
> -------------------------------------------
>
> Hi again,
>
> In dealing with the subject of my post above I came across the article (i=
n
> notebook form) by Robby Villegas (Wolfram Research) about Working with
> Unevaluated Expressions, which begins:
>
> "Most experienced Mathematica programmers will eventually encounter tasks=
 or
> 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=
hat
> 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=
wn
> way to the solution but I did not get to prevent the lhs of assignments f=
rom
> 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=
 be
> "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=
s
> can be made more flexible. Then he announces that he will expand the arti=
cle
> 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=
f
> this document (Working with Unevaluated Expressions)."
>
> Now, since "leaving unevaluated certain parts of *Set* rhs as exceptions"=
 is
> 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=
now
> 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