Jump to content

Multiplication tables: Difference between revisions

m
→‎AppleScript :: Functional: Tweaked types for simpler separation between model and display
m (→‎Applescript: Iteration: ( normalized indentation ))
m (→‎AppleScript :: Functional: Tweaked types for simpler separation between model and display)
Line 546:
on multiplicationTable(n)
tableText(mulTable(enumFromTo(1, n12)))
end multiplicationTable
 
 
-- mulTable :: [Int -> Int]-> [[StringInt]]
on mulTable(m, naxis)
set axis to enumFromTo(m, n)
script column
Line 560 ⟶ 559:
on |λ|(y)
if y < x then
""{}
else
({x * y) as string}
end if
end |λ|
end script
{{{x}} & map(row, axis)}
end |λ|
end script
{{"x"} & axis} & concatMap(column, axis)
end mulTable
 
 
-- tableText :: [[Int]] -> String
on tableText(lstTablerows)
script tableLine
on |λ|(lstLine)
Line 589:
end script
set axis to {{"x"}} & rest of (item 1 of rows)
intercalate(linefeed, map(tableLine, lstTable{axis} & rows))
end tableText
 
9,659

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.