MathGroup Archive 2011

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

Search the Archive

Re: How to Do a Replacement with Two Conditions


On Jun 16, 9:08 pm, Gregory Lypny <gregory.ly... at videotron.ca> wrote:
> Hello everyone,
>
> I have a list of integers and I want to replace numbers bigger than 180 with one and those less than or equal to 180 with 0 to create a dummy variable.  The ones are easy:
>
>         myList /. x_ /; x > 180 -> 1
>
> How do I get the zeros in there?
>
> Regards,
>
> Gregory

mylist = {179, 180, 181, 182};
UnitStep[mylist - 181]

{0, 0, 1, 1}


  • Prev by Date: Re: Nudge? (Coarse and Fine Manipulation)
  • Next by Date: webMathematica Export
  • Previous by thread: Re: How to Do a Replacement with Two Conditions
  • Next by thread: Re: How to Do a Replacement with Two Conditions