Multiplication tables: Difference between revisions

Content added Content deleted
Line 337: Line 337:
<lang AppleScript>on run
<lang AppleScript>on run
showTable(table(1, 12))
tableText(table(1, 12))
end run
end run
Line 343: Line 343:
-- MULTIPLICATION TABLE
-- MULTIPLICATION TABLE


-- Int -> Int -> [[String]]
-- table :: Int -> Int -> [[String]]
on table(m, n)
on table(m, n)
Line 373: Line 373:
-- TABLE DISPLAY
-- TABLE DISPLAY


-- [[String]] -> String
-- tableText :: [[String]] -> String
on showTable(lstTable)
on tableText(lstTable)
script mf
script mf
on showLine(lstLine)
-- tableLine :: [Int] -> String
on tableLine(lstLine)
intercalate(" ", ¬
intercalate(" ", ¬
map(showCell of mf of my closure, lstLine))
map(tableCell of mf of my closure, lstLine))
end showLine
end tableLine
on showCell(cell)
-- tableCell :: Int -> String
on tableCell(cell)
(characters -4 thru -1 of (" " & cell)) as string
(characters -4 thru -1 of (" " & cell)) as string
end showCell
end tableCell
end script
end script
intercalate(linefeed, map(mClosure(mf's showLine, {mf:mf}), lstTable))
intercalate(linefeed, map(mClosure(mf's tableLine, {mf:mf}), lstTable))
end showTable
end tableText