Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

Re: How to Do a Replacement with Two Conditions


Create a List with Random numbers and Map it to the function that does 
the replacement:

If[#1 > 180, 1, 0] & /@ Table[Random[] 200, {i, 1, 1000}]

Kind regards

Peter

Am 17.06.2011 12:09, schrieb Heike Gramberg:
> myList /. {x_ /; x>  180 ->  1, x_ /; x<= 180 ->  0}
>
> Heike.
>
> On 17 Jun 2011, at 05:07, Gregory Lypny 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
>>
>


-- 
Mit freundlichen Grüßen

Uta&  Peter Klamser



  • Prev by Date: Re: How to Do a Replacement with Two Conditions
  • Next by Date: Re: capacitor equation solution not working
  • Previous by thread: Re: How to Do a Replacement with Two Conditions
  • Next by thread: Re: How to Do a Replacement with Two Conditions