Apply hlint suggestions
This commit is contained in:
parent
15722908f4
commit
0c107d563e
2 changed files with 5 additions and 7 deletions
|
@ -49,7 +49,7 @@ listLSystemsParser = infoOption (printList lsystems)
|
||||||
splitOn :: Char -> String -> [String]
|
splitOn :: Char -> String -> [String]
|
||||||
splitOn c s = case dropWhile (== c) s of
|
splitOn c s = case dropWhile (== c) s of
|
||||||
"" -> []
|
"" -> []
|
||||||
s' -> w:(splitOn c s'')
|
s' -> w : splitOn c s''
|
||||||
where (w, s'') = break (== c) s'
|
where (w, s'') = break (== c) s'
|
||||||
|
|
||||||
colorParser :: Parser Color
|
colorParser :: Parser Color
|
||||||
|
@ -60,7 +60,7 @@ colorParser = option (eitherReader readRGB)
|
||||||
<> showDefault
|
<> showDefault
|
||||||
<> value white
|
<> value white
|
||||||
<> metavar "R,G,B")
|
<> metavar "R,G,B")
|
||||||
where readRGB s = do
|
where readRGB s =
|
||||||
case mapM readEitherSafe $ splitOn ',' s of
|
case mapM readEitherSafe $ splitOn ',' s of
|
||||||
Right (r:g:b:a:_) -> Right $ makeColorI r g b a
|
Right (r:g:b:a:_) -> Right $ makeColorI r g b a
|
||||||
Right (r:g:b:_) -> Right $ makeColorI r g b 255
|
Right (r:g:b:_) -> Right $ makeColorI r g b 255
|
||||||
|
|
|
@ -45,10 +45,8 @@ iterateLSystem 0 lsystem = lsystem
|
||||||
iterateLSystem n lsystem | n < 0 = iterateLSystem (-n) lsystem
|
iterateLSystem n lsystem | n < 0 = iterateLSystem (-n) lsystem
|
||||||
iterateLSystem n (LSystem na a ax r ang dist rep) =
|
iterateLSystem n (LSystem na a ax r ang dist rep) =
|
||||||
iterateLSystem (n-1) $ LSystem na a ax' r ang dist rep
|
iterateLSystem (n-1) $ LSystem na a ax' r ang dist rep
|
||||||
where ax' = concat $ map f ax
|
where ax' = concatMap f ax
|
||||||
f x = case lookup x r of
|
f x = fromMaybe [x] (lookup x r)
|
||||||
Just xs -> xs
|
|
||||||
Nothing -> [x]
|
|
||||||
|
|
||||||
-- | Generate a set of instructions from an L-system
|
-- | Generate a set of instructions from an L-system
|
||||||
instructions :: Eq a => LSystem a -> [Instruction]
|
instructions :: Eq a => LSystem a -> [Instruction]
|
||||||
|
@ -71,7 +69,7 @@ turtle angle distance = go 90 (Line [(0,0)]) (Pictures []) []
|
||||||
TurnLeft -> go (theta - angle) (Line path) (Pictures ps) stack xs
|
TurnLeft -> go (theta - angle) (Line path) (Pictures ps) stack xs
|
||||||
Push -> go theta (Line path) (Pictures ps) ((head path, theta):stack) xs
|
Push -> go theta (Line path) (Pictures ps) ((head path, theta):stack) xs
|
||||||
Pop -> let (pos, theta'):t = stack in
|
Pop -> let (pos, theta'):t = stack in
|
||||||
go theta' (Line [pos]) (Pictures ((Line path):ps)) t xs
|
go theta' (Line [pos]) (Pictures (Line path : ps)) t xs
|
||||||
Stay -> go theta (Line path) (Pictures ps) stack xs
|
Stay -> go theta (Line path) (Pictures ps) stack xs
|
||||||
where
|
where
|
||||||
(px, py) = head path
|
(px, py) = head path
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue