Minimum number of cells after, before, above and below NxN squares: Difference between revisions

m
→‎{{header|Haskell}}: Dropped Data.Bool
m (→‎{{header|Haskell}}: Dropped Data.Bool)
Line 1,453:
 
<syntaxhighlight lang="haskell">import Data.Bifunctor (bimap)
import Data.Bool (bool)
import Data.Matrix (Matrix, matrix)
 
Line 1,461 ⟶ 1,460:
distancesToEdge n = matrix n n (uncurry min . bimap f f)
where
f = bool . (-) n <*> pred <*> (<= m)
m = quot n 2
f i
| i <= m = pred i
| otherwise = n - i
 
--------------------------- TEST -------------------------
9,655

edits