Re: I want to convert a list of integers to their negative self
Re: I want to convert a list of integers to their negative self
- Subject: Re: I want to convert a list of integers to their negative self
- From: Emmanuel <email@hidden>
- Date: Wed, 28 Feb 2001 15:58:56 -0600
At 18:38 -0600 9/05/00, Jacco Rens wrote:
>
>
Hi all,
>
>
I want to convert a list of integers to their negative self
>
>
{"1", "3", "7", "", ""}
>
>
To:
>
>
{"-1", "-3", "-7", "", ""}
Here is a first start:
------------------------ tested, OS 9.0.4
set theList to {"1", "3", "7", "", ""}
repeat with theItem in theList
set contents of theItem to "" & (-1 * theItem)
end repeat
theList
-- {"-1", "-3", "-7", "0", "0"}
------------------------
This will not do exactly what you expect, because:
- empty strings will turn into zeros
- non-numeric strings will generate errors.
So, you may have to customize a little bit.
HTH
Emmanuel