fix a splitAtElement bug with adjacent separators
This commit is contained in:
parent
c1c9a989be
commit
f064ecf138
@ -259,12 +259,14 @@ difforzero a b = maximum [(a - b), 0]
|
|||||||
-- lists
|
-- lists
|
||||||
|
|
||||||
splitAtElement :: Eq a => a -> [a] -> [[a]]
|
splitAtElement :: Eq a => a -> [a] -> [[a]]
|
||||||
splitAtElement e l =
|
splitAtElement x l =
|
||||||
case dropWhile (e==) l of
|
case l of
|
||||||
[] -> []
|
[] -> []
|
||||||
l' -> first : splitAtElement e rest
|
e:es | e==x -> split es
|
||||||
where
|
es -> split es
|
||||||
(first,rest) = break (e==) l'
|
where
|
||||||
|
split es = let (first,rest) = break (x==) es
|
||||||
|
in first : splitAtElement x rest
|
||||||
|
|
||||||
-- trees
|
-- trees
|
||||||
|
|
||||||
@ -388,6 +390,8 @@ ptrace msg = do
|
|||||||
-- unsafePerformIO and can be accessed from anywhere and before normal
|
-- unsafePerformIO and can be accessed from anywhere and before normal
|
||||||
-- command-line processing. After command-line processing, it is also
|
-- command-line processing. After command-line processing, it is also
|
||||||
-- available as the @debug_@ field of 'Hledger.Cli.Options.CliOpts'.
|
-- available as the @debug_@ field of 'Hledger.Cli.Options.CliOpts'.
|
||||||
|
-- {-# OPTIONS_GHC -fno-cse #-}
|
||||||
|
-- {-# NOINLINE debugLevel #-}
|
||||||
debugLevel :: Int
|
debugLevel :: Int
|
||||||
debugLevel = case snd $ break (=="--debug") args of
|
debugLevel = case snd $ break (=="--debug") args of
|
||||||
"--debug":[] -> 1
|
"--debug":[] -> 1
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user