Re: Change the mod result in list
Re: Change the mod result in list
- Subject: Re: Change the mod result in list
- From: bill fancher <email@hidden>
- Date: Thu, 22 Aug 2002 23:56:18 -0700
On Thursday, August 22, 2002, at 10:54 AM, Michelle Steiner wrote:
Or you can do it this way:
set integerList to {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
set N to 4
set resultList to {}
repeat with i in integerList
set end of resultList to (i mod N) + 4 * ((i mod N = 0) as integer)
I like that. It quite literally does what was requested.
But for N = 5 we get {1, 2, 3, 4, 4, 1, 2, 3, 4, 4, 1, 2} which is
probably not really the desired result. If we change that line to:
set end of resultList to (i mod N) + N * ((i mod N = 0) as integer)
(which I suspect you meant to write) then we get {1, 2, 3, 4, 5, 1, 2, 3,
4, 5, 1, 2}.
As long as integerList has only positive values, as above, we can just do:
set end of resultList to 1 + (i - 1) mod N
--
a different bill
end repeat
--Michelle
On Thursday, August 22, 2002, at 10:14 AM, bill wrote:
Is there any possible way to convert each 0 to 4? Like this one:
We're not human beings having a spiritual experience.
We're spiritual beings having a human experience.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.