Magic squares of doubly even order: Difference between revisions

m
→‎{{header|AppleScript}}: ( slight reordering )
m (→‎{{header|AppleScript}}: ( slight reordering ))
Line 43:
{}
else
script scale
on lambda(x)
replicate(n / 4, x)
end lambda
end script
set sqr to n * n
Line 53 ⟶ 48:
set maybePowerOfTwo to asPowerOfTwo(sqr)
if maybePowerOfTwo is not missing value then
 
-- For integer powers of 2, the (append not) 'magic' series directly
-- yields the truth table that we need
set truthSeries to magicSeries(maybePowerOfTwo)
else
-- where n is not an integera power of 2, we can replicate a
-- minimum truth table, horizontally and vertically
script scale
on lambda(x)
replicate(n / 4, x)
end lambda
end script
set truthSeries to ¬
flatten(scale's lambda(map(scale, splitEvery(4, magicSeries(4)))))
Line 129 ⟶ 131:
 
 
-- GENERIC FUNCTIONS ---------------------------------------------------------------------------
 
-- splitEvery :: Int -> [a] -> [[a]]
9,659

edits