Magic squares of odd order: Difference between revisions
Content added Content deleted
m (J: oops, diagonals matter) |
|||
Line 387: | Line 387: | ||
to allow for first class functions and closures. |
to allow for first class functions and closures. |
||
<lang AppleScript>-- |
<lang AppleScript>---------------- MAGIC SQUARE OF ODD ORDER --------------- |
||
-- oddMagicSquare :: Int -> [[Int]] |
|||
on oddMagicSquare(n) |
on oddMagicSquare(n) |
||
if 0 < (n mod 2) then |
|||
cycleRows(transpose(cycleRows(table(n)))) |
cycleRows(transpose(cycleRows(table(n)))) |
||
else |
|||
missing value |
missing value |
||
end if |
|||
end oddMagicSquare |
end oddMagicSquare |
||
--------------------------- TEST ------------------------- |
|||
on run |
on run |
||
-- Orders 3, 5, 11 |
-- Orders 3, 5, 11 |
||
Line 448: | Line 453: | ||
-------------------- GENERIC FUNCTIONS ------------------- |
|||
-- intercalate :: Text -> [Text] -> Text |
-- intercalate :: Text -> [Text] -> Text |
||
Line 521: | Line 526: | ||
end transpose |
end transpose |
||
⚫ | |||
⚫ | |||
-- formattedTable :: [[Int]] -> String |
-- formattedTable :: [[Int]] -> String |