Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*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 2002

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

Search the Archive

Re: How To Change A Rule

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32375] Re: How To Change A Rule
  • From: Clemens Frey <frey at mathematik.tu-darmstadt.de>
  • Date: Thu, 17 Jan 2002 02:23:27 -0500 (EST)
  • Organization: TU Darmstadt
  • References: <a20mon$4hf$1@smc.vnet.net>
  • Reply-to: frey at mathematik.tu-darmstadt.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

you may use a simple transformation with a conditional pattern. 
Having a list of rules named rlst:

IN[1]:= rlst = {s1 -> -11, s2 -> 12}

then the following 

IN[2]:= rlst2 = rlst /. Rule[x_, y_ /; y < 0] -> Rule[x, 0] 

sets rlst2 to be the following list of rules:

OUT[2]= {s1 -> 0, s2 -> 12}


Hope that helps.

Clemens


Ariel Fligler wrote:
> 
> Greetings,
> 
> I'm quite newby to Mathematica programming and will thank you if you could
> help me solve the following:
> 
> I have a list of rules of the form:
> {s1->-11, s2->12}
> And would like to change every rule in the list that it's RHS is negative to
> 0 so that I will get:
> {s1->0, s2->12}
> I tried to find an access function to manipulate rules but could not.
> 
> Any help ?
> 
> TIA,
> 
> Ariel.
> 
> Thanks,
> 
> Ariel Fligler

-- 
----------------------------------------------------------
Clemens Frey                       phone: +49-6151-164706
Darmstadt University of Technology fax  : +49-170-137703191
Mathematical Institute, AG 10      cell : +49-170-7703191
Schloßgartenstraße 7          frey at mathematik.tu-darmstadt.de
D-64289 Darmstadt (Germany)   www.mathematik.tu-darmstadt.de/~frey/
----------------------------------------------------------


  • Prev by Date: RE: How To Change A Rule
  • Next by Date: Re: Taylor Series Expansions
  • Previous by thread: RE: How To Change A Rule
  • Next by thread: Fourier Description of a Distorted Circle