Multiplication tables: Difference between revisions

Line 53:
<lang AppleScript >set n to 12 -- Size of table.
repeat with x from 0 to n
if x = 0 then set {Rtable, x} to {{return}, -1}
repeat with y from 0 to n
if y's contents = 0 then
if x > 0 then set RRrow to {f(x as string)}
if x = -1 then set {RRrow, x} to {{f("x")}, 1}
else
if y ≥ x then set end of RRrow to f(x * y)
if y < x then set end of RRrow to f("")
end if
end repeat
set end of Rtable to RRrow & return
end repeat
return Rtable as string
 
-- Handler/Function for formatting fixed width integer string.
Line 71:
set text item delimiters to ""
return (characters -4 thru -1 of (" " & x)) as string
end f</lang>Output:
</lang>Output:
<pre>"
x 1 2 3 4 5 6 7 8 9 10 11 12
Anonymous user