Roman Numerals Conversion

Richmond Mathewson richmondmathewson at gmail.com
Thu Mar 25 13:47:38 EDT 2010


  On 25/03/2010 19:40, Mark Schonewille wrote:
> Oops, too quick....
>
> The second line of the script should be
>      put "1,5,10,50,100,500,1000" into myArabs
>
>
>
> function romanToArab theNumber
>      put "i,v,x,l,c,d,m" into myRomans
>      put "1,5,10,50,100,500,1000" into myArabs
>      put item itemoffset(last char of theNumber,myRomans) of myArabs 
> into myNumber
>      repeat with x = (number of chars of theNumber - 1) down to 1
>           put item itemoffset(char x of theNumber,myRomans) of myArabs 
> into myTemp1
>           put item itemoffset(char x + 1 of theNumber,myRomans) of 
> myArabs into myTemp2
>           if myTemp1 < myTemp2 then
>                subtract myTemp1 from myNumber
>           else add myTemp1 to myNumber
>      end repeat
>      return myNumber
> end romanToArab
>
> -- 
> Best regards,
>
> Mark Schonewille
Brilliant; although just at present it may be more politically correct to
put "1,5,10,50,100,500,1000" into yourArabs

one cannot be too careful nowadays . . . :)



More information about the use-livecode mailing list