Allow for some and/or in regexes

This commit is contained in:
2023-02-21 12:22:50 +00:00
parent e137e95b54
commit 495c38b9c7
2 changed files with 29 additions and 1 deletions
+9
View File
@@ -18,6 +18,8 @@ module ListHelp
, takeWhileArb
, takeWhileArb'
, foldrWhileArb
, wordsBy
) where
import Data.List
import Data.Ord
@@ -108,3 +110,10 @@ foldrWhileArb _ z _ _ _ [] = z
foldrWhileArb h z t f y (x:xs) = case f y x of
y' | t y' -> h x $ foldrWhileArb h z t f y' xs
| otherwise -> h x z
wordsBy :: Eq a => a -> [a] -> [[a]]
wordsBy x xs = case dropWhile (==x) xs of
[] -> []
xs' -> w : wordsBy x xs''
where
(w,xs'') = break (==x) xs'