Magic squares of singly even order: Difference between revisions

→‎{{header|Haskell}}: (Change tabulation of number thread from sort+group to Map.lookup)
(→‎{{header|Haskell}}: Tidied, used Map.lookup in lieu of !!)
(→‎{{header|Haskell}}: (Change tabulation of number thread from sort+group to Map.lookup))
Line 468:
let d = (2 * n) + 1 -- LUX table size
startXY = (quot d 2, 0) -- Middle of top row
in threadRows(threadTable (d * 2)) . concat . snd $
mapAccumR -- Numbering of higher-resolution coordinates
(\a (xy, c) -> (a + 4, luxNums xy c a))
Line 529:
 
-- Numbered sequence of coordinates -> ordered rows
threadRowsthreadTable :: Int -> [((Int, Int), Int)] -> [[Int]]
threadTable w path =
threadRows cells =
let rowmapPath = snd M.fromList fstpath
colaxis = fst[0 .. w - fst1]
in (fmap snd(fromJust . sortByflip (comparingM.lookup colmapPath) <$>
(axis groupBy>>= (on\x (-> [axis >>==) row)\y (sortBy-> [(comparing row)x, cellsy)]])
 
-- TESTS ----------------------------------------------------------------------
9,655

edits