Created
November 26, 2014 01:51
-
-
Save davidchambers/34fdbaf7e281b07ebf4b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
findX :: (MatchObj -> Maybe MatchObj) -> [String] -> Maybe MatchObj | |
findX matcher words = head xs | |
where | |
xs = do len <- length words .. 1 | |
idx <- 0 .. length words - len | |
let m = matcher { before: take idx words | |
, group: (drop idx >>> take len) words | |
, after: drop (idx + len) words | |
, matches: defaultTransaction | |
, context: [] | |
} | |
guard $ isJust m | |
return $ fromJust m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment