• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to calculate/process this one?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to calculate/process this one?


  • Subject: Re: How to calculate/process this one?
  • From: Jean-Baptiste Le Stang <email@hidden>
  • Date: Sat, 27 Apr 2002 15:44:14 +0200

> Hi,
>
> I have a problem thinking of a routine which does the following:
>
> Let's say I have a random number like 11050. Now I want to add each pair
> of consecutive digits to give the next line (so 11050 becomes 2155). I
> want to repeat this step until I have a two-digit number.
>
> I tried over and over again but did not find a solution for this problem.
>
> Anybody out there who could help me?
>
> With very kind regards,
>
> Martin
> _______________________________________________
> 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.

Try the following

set mynum to 11050 as string
set newnum to ""

repeat with x from 1 to (count mynum) - 1
set newnum to newnum & (((item x) of mynum) + ((item (x + 1)) of mynum)
as string)
end repeat

repeat until (newnum as integer < 100)
set mynum to newnum
set newnum to ""
repeat with x from 1 to (count mynum) - 1
set newnum to newnum & (((item x) of mynum) + ((item (x + 1)) of
mynum) as string)
end repeat
end repeat

JB Le Stang
_______________________________________________
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.

  • Follow-Ups:
    • Re: How to calculate/process this one?
      • From: Martin Michel <email@hidden>
References: 
 >How to calculate/process this one? (From: Martin Michel <email@hidden>)

  • Prev by Date: Re: How to calculate/process this one?
  • Next by Date: Exponential notation [was: Re: How to calculate/process this one?]
  • Previous by thread: Re: How to calculate/process this one?
  • Next by thread: Re: How to calculate/process this one?
  • Index(es):
    • Date
    • Thread