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: Michelle Steiner <email@hidden>
- Date: Wed, 28 Feb 2001 14:01:24 -0800
On 5/9/00 4:38 PM, Jacco Rens <email@hidden> wrote:
>
I want to convert a list of integers to their negative self
>
>
{"1", "3", "7", "", ""}
Well, first of all, if they're integers, why represent them as strings?
try this
set a to {"1", "3", "7", "", ""}
repeat with b from 1 to (count a)
set (item b of a) to -((item b of a) as number)
end repeat
a
This will return negative numbers (or positive, for negative input)
whether the originals are numbers or strings; it will convert "" to 0
though.
-->{-1, -3, -7, 0, 0}
--Michelle
----------------------------------------------------------------------
| Michelle Steiner | We're not human beings having a spiritual |
| | experience. We're spiritual beings |
| email@hidden | having a human experience. |
----------------------------------------------------------------------