print helper: fix & hindent
didn’t take into consideration that some elements might be duplicates ¯\_(ツ)_/¯
This commit is contained in:
parent
fbf0e75d8e
commit
74fe38337f
|
@ -0,0 +1,21 @@
|
||||||
|
module Snippets where
|
||||||
|
|
||||||
|
import Control.Lens
|
||||||
|
import Data.List
|
||||||
|
import Linear.V2
|
||||||
|
|
||||||
|
p :: Int -> [Int] -> String
|
||||||
|
p n (x:xs) =
|
||||||
|
if n == x
|
||||||
|
then '#' : p (n + 1) xs
|
||||||
|
else '.' : p (n + 1) (x : xs)
|
||||||
|
p _ [] = []
|
||||||
|
|
||||||
|
print2D :: Int -> [V2 Int] -> [String]
|
||||||
|
print2D n coords
|
||||||
|
| n == pred minY = []
|
||||||
|
| otherwise = p minX line : print2D (n - 1) coords
|
||||||
|
where
|
||||||
|
line = nub $ sort $ map (^. _x) (filter (\(V2 _ a) -> a == n) coords)
|
||||||
|
minY = minimum $ map (^. _y) coords
|
||||||
|
minX = minimum $ map (^. _x) coords
|
Loading…
Reference in New Issue
Block a user