aboutsummaryrefslogtreecommitdiff
path: root/rip.hs
diff options
context:
space:
mode:
Diffstat (limited to 'rip.hs')
-rw-r--r--rip.hs13
1 files changed, 7 insertions, 6 deletions
diff --git a/rip.hs b/rip.hs
index e10ddb5..25ff98f 100644
--- a/rip.hs
+++ b/rip.hs
@@ -12,12 +12,13 @@ booltoint True = 1
parenpairs :: String -> [(Int,Int)]
parenpairs = go 0 []
- where go _ [] [] = []
- go i st ('[':cs) = go (i+1) (i:st) cs
- go i (s:st) (']':cs) = (s,i) : go (i+1) st cs
- go i [] (']':cs) = error "rip -- unmatched closing bracket"
- go i st (_:cs) = go (i+1) st cs
- go _ (_:_) [] = error "rip -- unmatched open bracket"
+ -- index stack string
+ where go _ [] [] = []
+ go i st ('[':cs) = go (i+1) (i:st) cs
+ go i (s:st) (']':cs) = (s,i) : go (i+1) st cs
+ go i [] (']':cs) = error "rip -- unmatched closing bracket"
+ go i st (_:cs) = go (i+1) st cs
+ go _ (_:_) [] = error "rip -- unmatched open bracket"
-- returns string in and after codeblock
getcodeblock :: String -> Either () (String,String)