Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: mg67144: 3rd try!

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67194] Re: mg67144: 3rd try!
  • From: Peter Pein <petsie at dordos.net>
  • Date: Sun, 11 Jun 2006 23:07:59 -0400 (EDT)
  • References: <e6gdj8$nco$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

jackgoldberg at comcast.net schrieb:
> Hi again,
> 
> I am writing this after sending in a correction to the referenced post.  The correction is not yet posted, so if you will forgive me, here is the up-to-date version of my questions.
> 
> I have constructed a Module whose last line is 
> 
> L5=Apply[List, "a collection of equalities and inequalities such as the one given below"]
> 
> This Module returns something like this,
> 
> {x==y, -3<=u<=1,t==5}
> 
> If I set, bb = {x==y, -3<=u<=1,t==5} (outside the Module) and then use Replace all, say,
> 
> bb/.{a_,q_,b_}->-1,
> 
> I get what I expect:   {x==y, -1, t==5}.
Are you sure, you're using Mathematica? Your last input gives the result -1 (as it should).:
bb = {x == y, -3 <= u <= 1, t == 5};
bb /. {a_, q_, b_} -> -1
-1
>  This leads me to the reasonable(?) conclusion that I could put this last step inside the Module.  So, my new Module looks like this (at the end)
> 
> L5=Apply[List, "..."];           (The quotes is to save space.  An expression is there.)
If I understood you correctly, "..." stands for a _list_ of equations and inequalities. Apply[List,{some, list}] is superflous.

> L6=L5/.{a_,q_,b_}->-1  ]        (and the Module ends.)
> 
> When the new version is run, the /. has no effect.  Why?  So it appears that the replacement rule which works outside the Module fails in the Module.  To add to my confusion, if  L6 is given this way,
> 
Maybe the list L5 does not contain exactly three elements?

> L6=Position[L5,LessEqual[-3,u,1]]  ]
> 
> The Module returns  {}.
> 
> Help is needed.
> 
> Jack
> 
In[4]:=
Module[{L5 = {x == y, -3 <= u <= 1, t == 5}, L6},
   Print[Position[L5, -3 <= u <= 1]];
    L5 /. x0_ <= x_ <= x1_ -> Mean[{x0, x1}]]

 From In[4]:= (* the position of the inequality *)
{{2}}

Out[4]=
{x == y, -1, t == 5}

The only cause for your trouble, I can imagine is the use of global variables.

Peter


  • Prev by Date: Re: ? about Rule (rewritten)
  • Next by Date: Some questions regarding loops and lists.
  • Previous by thread: Re: mg67144: 3rd try!
  • Next by thread: Re: mg67144: 3rd try!