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: Richard 23 <email@hidden>
- Date: Wed, 28 Feb 2001 21:05:46 -0800
>
Hi all,
>
>
I want to convert a list of integers to their negative self
>
>
{"1", "3", "7", "", ""}
>
>
To:
>
>
{"-1", "-3", "-7", "", ""}
<snip>
>
But because I'm not handy with this, I get a bad result.
>
I could not find the trick anywhere in my books :-(
>
>
Thanks for the input
>
>
>
--
>
Best,
>
Jacco
>
Netherlands
Funny that this ties in with the first question I asked of the
User's list...what the heck is "negate" (in the AppleScript suite)
for?
Although this would be a perfect "swan song" response since it would
bring closure, a full circle if you will. Forget it. I'm not going
anywhwere!
The method I would use would also add functionality to the unused
term negate (I often do this for exists, make and other commands
that aren't implemented in AppleScript).
-- ---------------------------------------------------------
-- Preprocessed by Convert Script 1.0d4
-- ---------------------------------------------------------
-- author: Richard 23, date: Wednesday, February 28, 2001
-- ---------------------------------------------------------
on negate theList
set outList to {}
tell theList to repeat with i from 1 to length
try
item i as number
on error
0
end try
set end of outList to -result as string
end repeat
return outList as item
end negate
-- ---------------------------------------------------------
Jacco: although it doesn't matter much in this case, adding a
new item to the end of a list is often faster than concatenation
R23