Skip to content

Commit 7b3094b

Browse files
committed
fix convert and looprange
1 parent 514045d commit 7b3094b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

hs-src/Language/Egison/Core.hs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1067,8 +1067,10 @@ processMStatesAll depth streams = do
10671067
else mappend matches $ processMStatesAll (depth + 1) streams'
10681068
where
10691069
convert :: Map Int [a] -> [[a]]
1070-
convert = M.foldlWithKey (\l k x -> if length l <= k then l ++ (replicate (k - length l) []) ++ [x]
1071-
else let (xs, y:ys) = splitAt k l in xs ++ (x:ys)) []
1070+
convert ms = let ((start, root), ms') = M.deleteFindMin ms in
1071+
M.foldlWithKey (\l k x -> let k' = k - start in
1072+
if length l <= k' then l ++ (replicate (k' - length l) []) ++ [x]
1073+
else let (xs, y:ys) = splitAt k' l in xs ++ (x:ys)) [root] ms'
10721074

10731075
processMStatesLine :: Int -> MatchingStates -> EgisonM MatchingStates
10741076
processMStatesLine depth streams = do

hs-src/Language/Egison/ParserNonS.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ loopPat :: Parser EgisonPattern
654654
loopPat = keywordLoop >> parens (char '$' >> LoopPat <$> identVarWithoutIndex <*> (comma >> loopRange) <*> (comma >> pattern) <*> (comma >> option (NotPat WildCard) pattern))
655655

656656
loopRange :: Parser LoopRange
657-
loopRange = parens (try (LoopRange <$> expr <* comma <*> expr <* comma <*> option WildCard pattern)
657+
loopRange = parens (try (LoopRange <$> expr <* comma <*> expr <*> option WildCard (comma >> pattern))
658658
<|> (do s <- expr
659659
comma
660660
ep <- option WildCard pattern

0 commit comments

Comments
 (0)